Auto opening macro when loading a workbook

M

Mike Boardman

I really ought to know this but I have completely forgotten how to do it.

I'm sure it's something to do with switches or namng the macro, but none of
the methods I have tried work.

Can anyone help me out please? TIA
 
S

Simon Lloyd

Hiya Mike,

I'm pretty new this but i know this one, go to tools then macros the
macro you will see that the box is blank now start typing in the blan
box type this :- Auto_open then click create, you must use the unde
score...there are only 2 auto macros and f course the other i
Auto_close. When you hae created your macro just paste any recorde
code that u want to run on open in here!

hope this helps.

Simo
 
A

Anders S

Mike,

In the code for ThisWorkbook:

Private Sub Workbook_Open()
MsgBox "Do it"
End Sub

Excel 2002

HTH
Anders Silven
 
B

Bob Phillips

Mike,

Naming the macro Auto_Open is the old (tried and trusted) way, and goes in
a standard code module, but when events made their appearance we got
Workbook_Open, which goes in the ThisWorkbook module.

A thing to note about Auto_Open is that it does not get run if a workbook is
opened from VBA, so you would need to do it explicitly with "RunAutoMacros
xlAutoOpen"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top