Run on Open

J

jsl

I want to do a "run on open" so I set up the code in my file under
"Microsoft Project Objects" as follows (courtesy Jack's helpful
website)..

Private Sub Project_Open(ByVal pj As Project)

AddMyMenuBar

End Sub

The code for AddMyMenuBar is in the Global.MPT.

However whenever I open the Project file in which I've set all this up,
I get an error "Sub or function not defined."

My guess is that Project/VB is only looking locally for "AddMyMenuBar"
and not looking in the Global.mpt. From my miscellaneous reading, I
can't figure out what to change to set the scope appropriately.

I would prefer if at all possible to keep the code for "AddMyMenuBar"
in the global so that I don't have to copy it into every Project
schedule that needs to run the code on open.
 
J

JackD

Try referring to the macro like this:
----------snip------
Private Sub Project_Open(ByVal pj As Project)

Application.Macro "global.MPT!module1.AddMyMenuBar"

End Sub
---------snip----------
You will need to replace the "module1" with the name of the module that
AddMyMenuBar is located in.
 

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