Sarah23 said:
I'm not sure if I am just doing something wrong or what, but my macro still
isn't running when I open Project. It works fine when I use the shortcut I
added for it. Am I entering everything correctly? In the code window, I'm
selecting Project in the left menu and Open is selected automatically on the
right. Then in blank line between Private Sub and End Sub I'm typing the
name of my macro (in this case, OverdueTasks). Like so:
Private Sub Project_Open(By Val pj As Project)
OverdueTasks
End Sub
Is this correct? Do I need anything before closing the code window?
Because right now I'm saving, then closing Project and reopening it, and the
macro isn't running. I tested this same method in Excel and that worked
perfectly...so I'm not sure what to do. Sorry, I'm a total macro newbie.
Thanks for your help both of you!
Sarah,
I haven't done any Event macro in quite a while so I had to do a little
testing. The macro name needs to be a string and needs to be "called".
Here is the code that worked for me.
Private Sub Project_Open(By Val pj As Project)
Macro "OverdueTasks"
End Sub
If the Open code is attached to "ThisProject(your file)", you will need
to save the project and then close it. You do not need to quit Project.
If the Open code is attached to the Global (i.e. ThisProject(global.mpt)
then it will run whenever any project file is opened as Jan mentioned in
his reply.
Also, if the Open code is attached to a specific file you will probably
get a warning message to enable or disable macros when you open the
file. You can either put up with the message each time or you can set
your macro security level to "low" (the default is "medium"). If you do
not open strange Project files (i.e. may have evil macros), the low
setting is probably ok. To change the security setting, from Project go
to Tools/Macro/Security. Note: this is a Project level setting (i.e. it
applies to all Project files).
Hope this helps.
John