AutoOpen

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top