Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Syntax for Selecting Multiple Worksheets in Excel Using VFP
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Syntax for Selecting Multiple Worksheets in Excel Using VFP
Miscellaneous
Thread ID:
01142827
Message ID:
01142827
Views:
191
Hi All,

I haven't been on in awhile, I hope everyone is doing well.

Using VFP 9, I'm trying to select multiple worksheets in an Excel spreadsheet.

For example:

* Create Instance
oExcel=CreateObject('Excel.Application')

* Open the spreadhsheet
oWorkBook=oExcel.Workbooks.Open("MyExcelWorkbook.xls")

Now, If I wanted to select a single worksheet "Sheet 1", for example (and have it be the active worksheet), I can issue this:

oWorkbook.Sheets("Sheet 1").Select

However, I can't quite get the syntax for selecting more than one worksheet. As I usually will do, I created a macro to see what the VBA code would look like... To select 2 worksheets, this is what the macro looked like:

Sheets(Array("Sheet 1", "Sheet 2")).Select

Unforunately, that won't work in VFP ("Array not a program" error). (And before anyone suggests it, oWorkbook.Sheets(Array("Sheet 1", "Sheet 2")).Select doesnt work either. :-)

Any suggestions would be appreciated. In the past, I've always relied on Tamar's book (MS Office Automation with Visual FoxPro, Hentzenwerke Publishing), but in this particular case, I can't figure out how to replicate the VBA syntax in VFP.

Thanks,
Next
Reply
Map
View

Click here to load this message in the networking platform