Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I am not Excel programmer. I use visual basic, but my software interacts with the spreadsheet. I have the following problem. My code uses statements like the one below: oExcel.ActiveWorkbook.ActiveSheet.Cells(oExcel.Act iveCell.Row, oExLast).Value This works fine when user uses one spreadsheet only. But when the user opens another spreadsheet the first one is not ACTIVE anymore, however my code still needs to access the first sheet. So here is my problem. How to keep track of the first sheet? I tried to do the following: Dim oExcelWBk As Excel.Workbook ' This is the work book Dim oExcelWS As Excel.Worksheet ' This is the sheet oExcelWS = oExcel.ActiveWorkbook.ActiveSheet but there is Run time Error '91': Object variable or With block variable not set. How to do that properly? Your thoughts please, Jack |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try:
Set oExcelWS = oExcel.ActiveWorkbook.ActiveSheet -- Vasant "Jack" <replyto@newsgroup wrote in message ... Hello, I am not Excel programmer. I use visual basic, but my software interacts with the spreadsheet. I have the following problem. My code uses statements like the one below: oExcel.ActiveWorkbook.ActiveSheet.Cells(oExcel.Act iveCell.Row, oExLast).Value This works fine when user uses one spreadsheet only. But when the user opens another spreadsheet the first one is not ACTIVE anymore, however my code still needs to access the first sheet. So here is my problem. How to keep track of the first sheet? I tried to do the following: Dim oExcelWBk As Excel.Workbook ' This is the work book Dim oExcelWS As Excel.Worksheet ' This is the sheet oExcelWS = oExcel.ActiveWorkbook.ActiveSheet but there is Run time Error '91': Object variable or With block variable not set. How to do that properly? Your thoughts please, Jack |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to run when a particular sheet is opened | Excel Discussion (Misc queries) | |||
Track when a file has been opened | Excel Discussion (Misc queries) | |||
any way to track changes on a sheet using a list? | Excel Discussion (Misc queries) | |||
To fix a sheet in MS Office to be opened first always | Excel Worksheet Functions | |||
How Can I track changes in a Work Sheet? | Excel Worksheet Functions |