Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Worksheet.activate question

Stupid question time ...

How can I get the Worksheet_Activatecode (for sheet1) to activate from
Workbook_Open() (even if sheet1 is already active)?
I tried just sticking the Worksheet_Activate command in Workbook_Open(), but
that doesn't seem to be accessable from Workbook_Open().


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Worksheet.activate question

Why not just activate the sheet from Workbook_Open?

Worksheets("Sheet1").Activate

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Tim Coddington" wrote in message
...
Stupid question time ...

How can I get the Worksheet_Activatecode (for sheet1) to activate from
Workbook_Open() (even if sheet1 is already active)?
I tried just sticking the Worksheet_Activate command in Workbook_Open(),

but
that doesn't seem to be accessable from Workbook_Open().




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Worksheet.activate question

Because if the sheet is already active when the workbook opens,
Worksheet_Activate won't fire. Otherwise, Sheet(1).activate would be the
way to go.

"Bob Phillips" wrote in message
...
Why not just activate the sheet from Workbook_Open?

Worksheets("Sheet1").Activate

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Tim Coddington" wrote in message
...
Stupid question time ...

How can I get the Worksheet_Activatecode (for sheet1) to activate from
Workbook_Open() (even if sheet1 is already active)?
I tried just sticking the Worksheet_Activate command in Workbook_Open(),

but
that doesn't seem to be accessable from Workbook_Open().






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Worksheet.activate question

Uh. I mean Worksheets("Sheet1").Activate would be the way to go.
"Tim Coddington" wrote in message
...
Because if the sheet is already active when the workbook opens,
Worksheet_Activate won't fire. Otherwise, Sheet(1).activate would be the
way to go.

"Bob Phillips" wrote in message
...
Why not just activate the sheet from Workbook_Open?

Worksheets("Sheet1").Activate

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Tim Coddington" wrote in message
...
Stupid question time ...

How can I get the Worksheet_Activatecode (for sheet1) to activate from
Workbook_Open() (even if sheet1 is already active)?
I tried just sticking the Worksheet_Activate command in

Workbook_Open(),
but
that doesn't seem to be accessable from Workbook_Open().








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Worksheet.activate question


Worksheets("Sheet2").Activate
Worksheets("Sheet1").Activate

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Tim Coddington" wrote in message
...
Uh. I mean Worksheets("Sheet1").Activate would be the way to go.
"Tim Coddington" wrote in message
...
Because if the sheet is already active when the workbook opens,
Worksheet_Activate won't fire. Otherwise, Sheet(1).activate would be

the
way to go.

"Bob Phillips" wrote in message
...
Why not just activate the sheet from Workbook_Open?

Worksheets("Sheet1").Activate

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Tim Coddington" wrote in message
...
Stupid question time ...

How can I get the Worksheet_Activatecode (for sheet1) to activate

from
Workbook_Open() (even if sheet1 is already active)?
I tried just sticking the Worksheet_Activate command in

Workbook_Open(),
but
that doesn't seem to be accessable from Workbook_Open().












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Worksheet.activate question

Another way:

In the ThisWorkbook module:

Option Explicit
Private Sub Workbook_Open()
Call Sheet1.Worksheet_Activate
End Sub

in the Sheet1 module:
Option Explicit
Sub Worksheet_Activate()
MsgBox "hi from activate"
End Sub

Notice that I removed the word "Private" from the Sub line:
Private Sub Worksheet_Activate()

so the sub can be found.



Tim Coddington wrote:

Stupid question time ...

How can I get the Worksheet_Activatecode (for sheet1) to activate from
Workbook_Open() (even if sheet1 is already active)?
I tried just sticking the Worksheet_Activate command in Workbook_Open(), but
that doesn't seem to be accessable from Workbook_Open().


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Worksheet.activate question

I get a "Compiler Error:

Method or data member not found" error on that one (Call
Sheet1.Worksheet_Activate).

But makes me think. Would Worksheet_Activate for sheet1 be found in the VBA
object? I couldn't find it. Or perhaps in the VBA.IDE (none such exists)
object?

"Dave Peterson" wrote in message
...
Another way:

In the ThisWorkbook module:

Option Explicit
Private Sub Workbook_Open()
Call Sheet1.Worksheet_Activate
End Sub

in the Sheet1 module:
Option Explicit
Sub Worksheet_Activate()
MsgBox "hi from activate"
End Sub

Notice that I removed the word "Private" from the Sub line:
Private Sub Worksheet_Activate()

so the sub can be found.



Tim Coddington wrote:

Stupid question time ...

How can I get the Worksheet_Activatecode (for sheet1) to activate from
Workbook_Open() (even if sheet1 is already active)?
I tried just sticking the Worksheet_Activate command in Workbook_Open(),

but
that doesn't seem to be accessable from Workbook_Open().


--

Dave Peterson



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Worksheet.activate question

Try This

In module# insert
sub any_name()
Include all the statements in your Worksheet_Activate code
end sub

then call this procedure both when the workbook is opened and when
worksheet1 is activated.

"Tim Coddington" wrote:

I get a "Compiler Error:

Method or data member not found" error on that one (Call
Sheet1.Worksheet_Activate).

But makes me think. Would Worksheet_Activate for sheet1 be found in the VBA
object? I couldn't find it. Or perhaps in the VBA.IDE (none such exists)
object?

"Dave Peterson" wrote in message
...
Another way:

In the ThisWorkbook module:

Option Explicit
Private Sub Workbook_Open()
Call Sheet1.Worksheet_Activate
End Sub

in the Sheet1 module:
Option Explicit
Sub Worksheet_Activate()
MsgBox "hi from activate"
End Sub

Notice that I removed the word "Private" from the Sub line:
Private Sub Worksheet_Activate()

so the sub can be found.



Tim Coddington wrote:

Stupid question time ...

How can I get the Worksheet_Activatecode (for sheet1) to activate from
Workbook_Open() (even if sheet1 is already active)?
I tried just sticking the Worksheet_Activate command in Workbook_Open(),

but
that doesn't seem to be accessable from Workbook_Open().


--

Dave Peterson




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Worksheet.activate question

When you're in the VBE, select your project.
hit * (on the number keypad) to expand all the branches.

Under Microsoft Objects branch, you'll see the worksheet names.

sheet1(MySheetNameHere)
sheet2(MyotherSheet)
....

The names in parentheses are the worksheet names that you can see when you're in
excel.

The name before the worksheet name is called the CodeName.

The code I suggested uses that CodeName.

So find the name of your worksheet and use that sheet's codename in this line:

Call Sheet1.Worksheet_Activate

(Remember to remove that "Private" portion in that sub, too.)

Those were two ways I could get the same error as you--wrong codename and
failing to remove Private.



Tim Coddington wrote:

I get a "Compiler Error:

Method or data member not found" error on that one (Call
Sheet1.Worksheet_Activate).

But makes me think. Would Worksheet_Activate for sheet1 be found in the VBA
object? I couldn't find it. Or perhaps in the VBA.IDE (none such exists)
object?

"Dave Peterson" wrote in message
...
Another way:

In the ThisWorkbook module:

Option Explicit
Private Sub Workbook_Open()
Call Sheet1.Worksheet_Activate
End Sub

in the Sheet1 module:
Option Explicit
Sub Worksheet_Activate()
MsgBox "hi from activate"
End Sub

Notice that I removed the word "Private" from the Sub line:
Private Sub Worksheet_Activate()

so the sub can be found.



Tim Coddington wrote:

Stupid question time ...

How can I get the Worksheet_Activatecode (for sheet1) to activate from
Workbook_Open() (even if sheet1 is already active)?
I tried just sticking the Worksheet_Activate command in Workbook_Open(),

but
that doesn't seem to be accessable from Workbook_Open().


--

Dave Peterson


--

Dave Peterson
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
Activate Object question Eva Excel Worksheet Functions 0 December 14th 07 12:41 AM
Activate Object question Eva Excel Worksheet Functions 0 December 14th 07 12:41 AM
Worksheet.activate Jeff Excel Discussion (Misc queries) 1 December 14th 04 01:52 PM
Worksheet activate Lee Hunter[_2_] Excel Programming 2 August 25th 04 05:55 PM
Userform activate event question dan Excel Programming 1 January 26th 04 04:14 PM


All times are GMT +1. The time now is 08:36 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"