View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jan Karel Pieterse Jan Karel Pieterse is offline
external usenet poster
 
Posts: 535
Default Run a macro when a workbook is opened

Hi,


Workbook_Open is an "event procedure" and needs to go in
the module of the ThisWorkbook object.

Alt+F11 to the VB editor
In the project explorer window double-click the
ThisWorkbook entry under Microsoft Excel Objects.
In the code window which should now be showing you the
module for ThisWorkbook:
- select Workbook from the left hand dropdown at the top
of the window
- select Open from the right hand dropdown [may have
happened automatically]
- type your code between the lines
Private Sub Workbook_Open()
and
End Sub
which will have been generated automatically.

Regards,

Jan Karel Pieterse
Excel TA/MVP

-----Original Message-----
I know its there somewhere but I cannot find help on how

to run a macro
which runs automatically when a workbook is opened and

again how to run a
macro when a workbook is closed.
I can't figure out how to run open and close events!
Can anyone get me started?



.