Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA code in VB

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I wrote some Excel VBA code that goes through each textbox in a given worksheet and extract text from it. This code works fine in VBA. But, when I move it over to VB so that I can package it as an exe, it does not work.

I have referenced the Excel 9.0 object library, and all myother code works fine, except this one line

Dim tbox as ITextBox
For Each tbox in ActiveSheet.ITextboxes
tbox.Select
-----------

It crashes on the FOR line with an error message
"Object doesn't support this property ot method"

Any help into why this is not working in VB would be much appreciated.

Thanks,
vwadhwan
 
Activesheet implies the existance of an actual spreadsheet. So, there needs to be a definition and instantation of Excel for this to 'work'. On the other hand, if you started from Excel, it seems only reasonable that you have that 'eleswhere' in the program. Perhaps the elsewhere is not in scope when you are executing this snippet?

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top