Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Why wouldn't calling the Activate sub for a sheet automatically call that sheet's Worksheet_Activate() sub?

I'm encountering the strangest thing, and I'm trying to figure out why it's
doing what it's doing.


Basically, my application is a VBA app, written in Excel 2002. In the
"ThisWorkbook.Workbook_Open" sub, there is a line that activates the first
tab. The line of code looks like this:

shtStart.Activate

Where shtStart is the name of the worksheet in question.


Within that worksheet's VBA code, there is the WorkSheet_Activate() sub, and
code within it.


But it seems that when the shtStart.Activate in the Workbook_Open sub is
called, it's not then (automatically) calling the WorkSheet_Activate() in
shtStart. I've even put break-points in the WorkSheet_Activate() sub, and
then ran the Workbook_Open sub (one line at a time), and still not hitting
the WorkSheet_Activate() sub.


What am I missing? Any ideas/suggestions?


Thanks!
-Scott


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Why wouldn't calling the Activate sub for a sheet automatically call that sheet's Worksheet_Activate() sub?

Is shtStart already the activesheet because it was the activesheet when you
last saved the workbook. Unless another sheet is active and you activate
shtStart, the activate event does not fire.

--
Regards,
Tom Ogilvy

"Scott Lyon" <scott.lyonNOSPAM_at__NOSPAMrapistan.comNOSPAM wrote in
message ...
I'm encountering the strangest thing, and I'm trying to figure out why

it's
doing what it's doing.


Basically, my application is a VBA app, written in Excel 2002. In the
"ThisWorkbook.Workbook_Open" sub, there is a line that activates the first
tab. The line of code looks like this:

shtStart.Activate

Where shtStart is the name of the worksheet in question.


Within that worksheet's VBA code, there is the WorkSheet_Activate() sub,

and
code within it.


But it seems that when the shtStart.Activate in the Workbook_Open sub is
called, it's not then (automatically) calling the WorkSheet_Activate() in
shtStart. I've even put break-points in the WorkSheet_Activate() sub, and
then ran the Workbook_Open sub (one line at a time), and still not hitting
the WorkSheet_Activate() sub.


What am I missing? Any ideas/suggestions?


Thanks!
-Scott




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Why wouldn't calling the Activate sub for a sheet automatically call that sheet's Worksheet_Activate() sub?

because the event will be triggered only when there are a
change on the active sheet(If the active sheet is shtStart
there will not execute the event), you need to use a code
like this:


If ActiveSheet.Name = "shtStart" Then
Call Workbook_SheetActivate(shtStart)
Else
shtStart.Activate
End If



-----Original Message-----
I'm encountering the strangest thing, and I'm trying to

figure out why it's
doing what it's doing.


Basically, my application is a VBA app, written in Excel

2002. In the
"ThisWorkbook.Workbook_Open" sub, there is a line that

activates the first
tab. The line of code looks like this:

shtStart.Activate

Where shtStart is the name of the worksheet in question.


Within that worksheet's VBA code, there is the

WorkSheet_Activate() sub, and
code within it.


But it seems that when the shtStart.Activate in the

Workbook_Open sub is
called, it's not then (automatically) calling the

WorkSheet_Activate() in
shtStart. I've even put break-points in the

WorkSheet_Activate() sub, and
then ran the Workbook_Open sub (one line at a time), and

still not hitting
the WorkSheet_Activate() sub.


What am I missing? Any ideas/suggestions?


Thanks!
-Scott


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Why wouldn't calling the Activate sub for a sheet automatically call that sheet's Worksheet_Activate() sub?

Ahhh, that worked. Thanks guys!

-Scott

"pancho" wrote in message
...
because the event will be triggered only when there are a
change on the active sheet(If the active sheet is shtStart
there will not execute the event), you need to use a code
like this:


If ActiveSheet.Name = "shtStart" Then
Call Workbook_SheetActivate(shtStart)
Else
shtStart.Activate
End If



-----Original Message-----
I'm encountering the strangest thing, and I'm trying to

figure out why it's
doing what it's doing.


Basically, my application is a VBA app, written in Excel

2002. In the
"ThisWorkbook.Workbook_Open" sub, there is a line that

activates the first
tab. The line of code looks like this:

shtStart.Activate

Where shtStart is the name of the worksheet in question.


Within that worksheet's VBA code, there is the

WorkSheet_Activate() sub, and
code within it.


But it seems that when the shtStart.Activate in the

Workbook_Open sub is
called, it's not then (automatically) calling the

WorkSheet_Activate() in
shtStart. I've even put break-points in the

WorkSheet_Activate() sub, and
then ran the Workbook_Open sub (one line at a time), and

still not hitting
the WorkSheet_Activate() sub.


What am I missing? Any ideas/suggestions?


Thanks!
-Scott


.



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
Calling name of Sheet as a Variable? thekeytothedoor Excel Worksheet Functions 1 January 1st 10 08:48 AM
Calling a macro from Worksheet--Activate Fatz Excel Discussion (Misc queries) 3 March 5th 08 11:07 PM
can i call the ukraine on a prepaid calling card mission man Excel Discussion (Misc queries) 1 December 7th 05 01:08 AM
how can i call a sub() automatically when someone click on sheet1 Saadi Excel Worksheet Functions 2 January 7th 05 08:37 PM
Automation Procedure with Worksheet_Activate If Excel Programming 2 July 11th 03 12:15 AM


All times are GMT +1. The time now is 03:53 AM.

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"