Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using GetObject() to retrieve open workbook
Message
 
To
11/06/2004 13:55:22
Jason Lanier
Ofs Brightwave Carrollton
Carrollton, Georgia, United States
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00912825
Message ID:
00912906
Views:
14
Sorry, not quite clear what do you mean, "still cannot find a reference to the sheet". Do you get any errors?

Probably there is no active sheet, or you need to activate the workbook, or there is no sheet with the name "Sheet1".


>I am having a problem assigning an open Pivot Table in Excel to an object. The following code works fine if opening it:
>
>oExcel = CreateObject("EXCEL.APPLICATION")
>oExcel.Application.Visible = .T.
>oExcel.Workbooks.Open("PivotTableExample.xls")
>oExcel.Sheets("Sheet1").Select
>
>The problem is if Excel is already running with the sheet as the active workbook. I've tried:
>
>oExcel = GetObject(,"EXCEL.APPLICATION")
>oWorkBook = oExcel.ActiveWorkbook
>and referencing by
>oExcel.Sheets("Sheet1").Select
>
>or
>
>oExcel = GetObject("PivotTableExample.XLS","EXCEL.SHEET")
>(This works, but I still cannot find the reference to the sheet.)
>
>but neither work. How can I assign the object to an open workbook/sheet without having to start with having to close and then re-start Excel?
>
>Thanks,
>Jason
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform