Auto Open Macro

L

Launchnet

Does anyone know of a Macro such as: Auto_Open or On_Open.
I think there is something someplace in Excel or VB that has this command.
Please let me know where it is at, if there is one. I can not find either in
Excel Help or VB Help.

Thanks
Matt@Launchnet
 
G

Gord Dibben

Auto_open will do the trick if placed into a General module.

Sub Auto_Open()
msgbox "Good Morning"
or run a macro by name
End Sub

Workbook_Open is used in Thisworkbook module.

Private Sub Workbook_Open()
msgbox "Good Morning"
or run a macro by name
End Sub

If you go to VB help and type in "workbook event code" you will get a list of
supported events.


Gord Dibben MS Excel MVP
 
L

Launchnet via OfficeKB.com

Hi Gord

Sorry, my coding is terrible. I tried test 1 & 2 and naturally, neither
worked.
I really want Test 2 to run when the workbook is opened.
All my macros are in the General Module and that is where I placed the below
code.

Thanks for your help in advance
Matt@Launchnet

Sub auto_open()
MsgBox "Welcome to MyMenu"

'Test 1
Run_macro Picture3_Click 'Picture3_Click is the macro I
want to run only

'Test 2
Application.Goto Reference:="R1C1" 'or . . . this row only.

End Sub

Gord said:
Auto_open will do the trick if placed into a General module.

Sub Auto_Open()
msgbox "Good Morning"
or run a macro by name
End Sub

Workbook_Open is used in Thisworkbook module.

Private Sub Workbook_Open()
msgbox "Good Morning"
or run a macro by name
End Sub

If you go to VB help and type in "workbook event code" you will get a list of
supported events.

Gord Dibben MS Excel MVP
Does anyone know of a Macro such as: Auto_Open or On_Open.
I think there is something someplace in Excel or VB that has this command.
[quoted text clipped - 3 lines]
Thanks
Matt@Launchnet
 
D

Dave Thomas

Did you put Call Test2 in the auto_open subroutine?
Your coding doesn't show it. If you don't call it, Test2 won't get done.
You can use either Call Test2 or simply Test2()


Launchnet via OfficeKB.com said:
Hi Gord

Sorry, my coding is terrible. I tried test 1 & 2 and naturally, neither
worked.
I really want Test 2 to run when the workbook is opened.
All my macros are in the General Module and that is where I placed the
below
code.

Thanks for your help in advance
Matt@Launchnet

Sub auto_open()
MsgBox "Welcome to MyMenu"

'Test 1
Run_macro Picture3_Click 'Picture3_Click is the macro I
want to run only

'Test 2
Application.Goto Reference:="R1C1" 'or . . . this row only.

End Sub

Gord said:
Auto_open will do the trick if placed into a General module.

Sub Auto_Open()
msgbox "Good Morning"
or run a macro by name
End Sub

Workbook_Open is used in Thisworkbook module.

Private Sub Workbook_Open()
msgbox "Good Morning"
or run a macro by name
End Sub

If you go to VB help and type in "workbook event code" you will get a list
of
supported events.

Gord Dibben MS Excel MVP
Does anyone know of a Macro such as: Auto_Open or On_Open.
I think there is something someplace in Excel or VB that has this
command.
[quoted text clipped - 3 lines]
Thanks
Matt@Launchnet

--
Please take a look at www.openoursite.com Click on: "Keywords" and then
Click on "Matt's Story" and if you are a man, you should be very happy
that
you read my story. God Bless for everyones help.
 
L

Launchnet via OfficeKB.com

Here is what I tried:

Sub auto_open()
MsgBox ("Welcome to MyMenu")
Picture3_Click() 'This is my sub-routine name
End Sub

The message box does not appear and sub-routine Picture3_Click() did not do
anything

I even tried Call Picture3_Click()
when i moved off that code line the () disappeared - It still didn't work
either.

Help Again Pleasee

Matt@Launchnet

Dave said:
Did you put Call Test2 in the auto_open subroutine?
Your coding doesn't show it. If you don't call it, Test2 won't get done.
You can use either Call Test2 or simply Test2()
[quoted text clipped - 46 lines]
 
D

Dave Thomas

I inserted a module in a new workbook, put the code below in it, saved it,
closed it , opened it and got the 2 messages shown below..

Sub auto_open()
MsgBox ("here in autoopen")
Call testit
End Sub
Sub testit()
MsgBox ("This is testit")
End Sub

Launchnet via OfficeKB.com said:
Here is what I tried:

Sub auto_open()
MsgBox ("Welcome to MyMenu")
Picture3_Click() 'This is my sub-routine name
End Sub

The message box does not appear and sub-routine Picture3_Click() did not
do
anything

I even tried Call Picture3_Click()
when i moved off that code line the () disappeared - It still didn't work
either.

Help Again Pleasee

Matt@Launchnet

Dave said:
Did you put Call Test2 in the auto_open subroutine?
Your coding doesn't show it. If you don't call it, Test2 won't get done.
You can use either Call Test2 or simply Test2()
[quoted text clipped - 46 lines]
Thanks
Matt@Launchnet

--
Please take a look at www.openoursite.com Click on: "Keywords" and then
Click on "Matt's Story" and if you are a man, you should be very happy
that
you read my story. God Bless for everyones help.
 
J

Jim Cone

Just in case...
If a workbook is opened using VBA code then any Auto_Open macros
will not run. They must be called using the RunAutoMacros method.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Dave Thomas" <[email protected]>
wrote in message
I inserted a module in a new workbook, put the code below in it, saved it,
closed it , opened it and got the 2 messages shown below..

Sub auto_open()
MsgBox ("here in autoopen")
Call testit
End Sub
Sub testit()
MsgBox ("This is testit")
End Sub
 
L

Launchnet via OfficeKB.com

Thanks Everybody. I was for ease in development only, opening my file with a
macro.
As soon as I tried it opening it directly from Excel, it works fine.

Again Thanks
Matt@Launchnet
 
Top