Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to run when a particular sheet is opened Derek N Excel Discussion (Misc queries) 4 July 24th 09 05:10 PM
Track when a file has been opened Judy Excel Discussion (Misc queries) 2 August 24th 07 04:02 PM
any way to track changes on a sheet using a list? Karenatallied Excel Discussion (Misc queries) 2 September 1st 06 03:37 PM
To fix a sheet in MS Office to be opened first always Shariq Excel Worksheet Functions 3 January 17th 06 11:59 AM
How Can I track changes in a Work Sheet? SiliconAlleyDude Excel Worksheet Functions 4 March 29th 05 10:17 AM


All times are GMT +1. The time now is 06:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"