>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)
loSheets = loWorkBook.Sheets
FOR i = 1 TO loSheets.COUNT
loSheet = loSheets.ITEM(i)
IF UPPER(loSheet.NAME) = 'DATA SHEET'
EXIT
ENDIF
ENDFOR
Bret Hobbs
"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope