Run Macro on Multiple Events

T

tommcbrny

Hello,

I found a link to running Macros on events from another thread here (pointed
to Jack Dahlgren's page, very useful).

I would like my macro to run when any one of multiple Project events occurs,
however, and do not see how to do this. I would like the macro run when a
project file is opened, when saved, and when closed, for instance. Can this
be done?

Thank you,

Tom
 
J

John

tommcbrny said:
Hello,

I found a link to running Macros on events from another thread here (pointed
to Jack Dahlgren's page, very useful).

I would like my macro to run when any one of multiple Project events occurs,
however, and do not see how to do this. I would like the macro run when a
project file is opened, when saved, and when closed, for instance. Can this
be done?

Thank you,

Tom

Tom,
You should be able to create and automatically run a macro when a file
is opened using:
Private Sub Project_Open(ByVal pj As MSProjet.Project)

Similarly when a file is saved, try the ProjectBeforeSave Event or the
BeforeSave Event. And when a file is closed, use the ProjectBeforeClose
Event or the BeforeClose Event. Details of each of those events can be
found in the Project Object Model under the Visual Basic Help menu.

Each of the above would be a separate Private sub in the ThisProject
object.

John
Project MVP
 

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

Top