Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
AutoOpen
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! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
AutoOpen
You can also keep your macro in a general module, but name it: Auto_open
(note the underscore) If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/getstarted.htm If you're new to events, David also has notes at: http://www.mvps.org/dmcritchie/excel/event.htm Chip Pearson also has some notes about events at: http://www.cpearson.com/excel/events.htm (just to add to Rob's reply) Tom Renoe wrote: 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! -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to disable autoopen() programmatically | Excel Programming | |||
'Yes' 'No' button on autoopen macro | Excel Programming | |||
Disable AutoOpen macro's | Excel Programming |