Thread: AutoOpen
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rob van Gelder[_4_] Rob van Gelder[_4_] is offline
external usenet poster
 
Posts: 1,236
Default AutoOpen

Sounds like you've got the hang of macros already, just need some exposure
to events.

From VBA, doubleclick the ThisWorkbook object and insert this code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
MsgBox ThisWorkbook.Name
End Sub

Private Sub Workbook_Open()
MsgBox "Workbook_Open"
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Tom Renoe" <Tom wrote in message
...
I am trying to write a macro that will run each time I open a particular
workbook. The macro has been written, tested and stored in the workbook
but I
cannot find out how to run it when I open the workbook.

I would also like to perform a Save As of this workbook if the workbook
name
equals MyWorkbook but allow a regular save if the name does not equal
MyWorkbook.

Thanks, I appreciate the help!