Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How to get worksheet_activate code to run when a workbook is opened

I have code in the worksheet_activate event for each of the worksheets in a
workbook. When the workbook is opened the worksheet_activate event for the
worksheet that was active at the last save is not fired.

I tried to get around this by placing "Worksheets(PROJECTS_WKS).Activate" in the
workbook_open event. The PROJECTS_WKS constant holds the name of the first
worksheet in the workbook. This only works if PROJECTS_WKS wasn't the active
worksheet at the time of the last save.

Is there anyway at workbook open time to get the worksheet_activate event to
fire for the worksheet that was active when the last save was done?

I know I could turn off screen updating and then activate some other worksheet
in the workbook and then switch back to one that was active to get the event to
fire.

That would work unless the workbook only contains one worksheet. I suppose then
I could just but the code that is in worksheet_activate into the workbook_open
event.

Is there some solution that would work in both cases.

Thanks

Mike Clemens
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How to get worksheet_activate code to run when a workbook isopened

Mike Clemens wrote:
I have code in the worksheet_activate event for each of the worksheets
in a workbook. When the workbook is opened the worksheet_activate event
for the worksheet that was active at the last save is not fired.

I tried to get around this by placing
"Worksheets(PROJECTS_WKS).Activate" in the workbook_open event. The
PROJECTS_WKS constant holds the name of the first worksheet in the
workbook. This only works if PROJECTS_WKS wasn't the active worksheet at
the time of the last save.

Is there anyway at workbook open time to get the worksheet_activate
event to fire for the worksheet that was active when the last save was
done?

I know I could turn off screen updating and then activate some other
worksheet in the workbook and then switch back to one that was active to
get the event to fire.

That would work unless the workbook only contains one worksheet. I
suppose then I could just but the code that is in worksheet_activate
into the workbook_open event.

Is there some solution that would work in both cases.

Thanks

Mike Clemens


Shortly after I sent the post to the newsgroup I came up with a solution. I
changed the all of the worksheet_activate procedures from private to public and
added the following code at the end of the workbook_open event procedu

Select Case ActiveSheet.Name
Case PROJECTS_WKS: Call WKS_Projects.Worksheet_Activate
Case PID_WKS: Call WKS_PID.Worksheet_Activate
Case SERVICEITEM_WKS: Call WKS_ServiceItem.Worksheet_Activate
Case CLASS_WKS: Call WKS_Class.Worksheet_Activate
Case USERS_WKS: Call WKS_Users.Worksheet_Activate
End Select
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
Running code in opened workbook Nigel RS[_2_] Excel Programming 2 October 15th 07 04:55 PM
Excel vba code disappears when saved workbook is re opened Joshua Fandango[_2_] Excel Programming 5 April 5th 05 04:12 PM
How to find out the residing directory of the opened workbook using VBA code ? Adrian[_7_] Excel Programming 2 August 7th 04 11:34 AM
Code to check if workbook is the last one opened KimberlyC Excel Programming 1 February 13th 04 12:04 AM
Code to tell if workbook is opened in browser BrianB Excel Programming 5 August 19th 03 02:47 PM


All times are GMT +1. The time now is 11:41 PM.

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

About Us

"It's about Microsoft Excel"