Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel Automation setting the active page.
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00658890
Message ID:
00658898
Views:
13
>>When adding a new sheet to an Excel Workbook, it is easy to make that newly add sheet the active sheet. However, I cannot make sheet 2 or 3 the active worksheet.
>>
>>OExcel.Worksheets.Add
>>osheet = OExcel.Worksheets(4)
>>osheet = OExcel.ActiveSheet
>>
>>** osheet is work sheet 4 which was just added.
>>
>>osheet = OExcel.WorkSheets(2)
>>osheet = OExcel.ActiveSheet
>>
>>** osheet remains the last active worksheet.
>>
>>How can I set the active worksheet to sheet 2 and 3?
>
>To get to the sheet I want I used the following code. It may help you. I was looking for a Sheet called 'DATA SHEET' you need only find the number of the item you are interested in.
>
>
>loExcel = CREATEOBJECT("Excel.Application")
>loWorkBook = loExcel.Workbooks.OPEN(lcExcelFileFullPath)
>* Get a reference to the Sheets in the Excel spreadsheet
>loSheets = loWorkBook.Sheets
>* Now that we have a sheets collection lets
>* get the one we want to update
>FOR i = 1 TO loSheets.COUNT
>  loSheet = loSheets.ITEM(i)
>  IF UPPER(loSheet.NAME) = 'DATA SHEET'
>    * We found what we want to work with
>    EXIT
>  ENDIF
>ENDFOR
>
>
I need to active a specific sheet. I am attempting to select a range of cells which only appears to work on the active sheet. I can access cells on any sheet without making that sheet the active sheet.
Fred Lauckner

You know, it works on my computer. I don't know what your problem is.

.Net aint so bad.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform