![]() |
How to keep track of opened sheet?
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 |
How to keep track of opened sheet?
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 |
All times are GMT +1. The time now is 11:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com