Click here to Skip to main content
15,945,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys

i am new to vsto and trying to convert my existing vba code to vsto code. there is something confusing me. Why should we use Ctype to convert a range object to Excel.Range even if range itself returns a range type rather than object type.

the code ise below. if i dont use Ctype, it gives error(option strcit doesnt allow late binding)

app here represents Excel.Application

CType(app.Columns("A:A"), Excel.Range)

Note:option strict is on, and i deliberately left it on. and i cast all the object-type-returning objects to the relevant type, like Excel.Range, Excel.WorkSheet etc. but i thought i was not supposed to cast range itself or columns to Excel.Range. why am i forced to do this?
Maciej Los 21-Sep-15 16:18pm    
why am i forced to do this? - you're the only persion who can answer this question!
ExcelinEfendisi 21-Sep-15 16:23pm    
didnt get what you mean?
Maciej Los 21-Sep-15 16:42pm    
I understand you very well. I wanted to show you that your question makes no sense.
ExcelinEfendisi 21-Sep-15 16:46pm    
uh huh. i searched a bit more and i got it now. it was just a misconception. it was just stupid of me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900