Is there an alternative to Auto_Open for when MS Project lauches.



I want to have a macro in my global.mpt that will activate when MS Project launches regardless of the schedule file.

I'm only looking for it to happen that once (to modify the xml in some custom ribbons) and do not need it to activate for each file open.

Is there such a macro entry that I can use? (I'm using MS Project Online Desktop)

Thanks in advance

7 Replies
Unfortunately there has been no response so I'm now assuming that having a macro run when launching MS Project is not possible.
I was hoping for something along the lines of AutoExec is MS Word.
However I will still thank those who took the time to consider this query.
Gilgamesh1964 --

I want to apologize for not responding to your question sooner. I was hoping that one of our VBA gurus would answer your question, but that did not happen.

So, allow me to take a stab at answering your question. First of all, you definitely want to use the Auto_Open macro to run the VBA code whenever Microsoft Project is launched. I believe you will want to add this macro to the Enterprise Global file so that it runs automatically for every user each time they launch Microsoft Project and connect to Project Online.

When the code runs, however, you need to test Microsoft Project to determine if the macro code has already run and has modified the ribbons. My recommendation for this test would be to create a custom enterprise Project field named something like Ribbon_Updated. Make the field a custom Flag field and set the default value to No for this field.

Then in your Auto_Open macro, perform a test on the Ribbon_Updated field. If the value is No, then the rest of the macro code should run. If the value is Yes, the macro should exit after the test and not run any further.

Don't know if this is any help to you, but at least I tried. Let us know how things go.
Gilgamesh1964 --

After posting my first response, I had another idea for you. Why don't you create a new blank project named something like Update Ribbons? In that project file, create a Project_Open macro that contains the VBA code for updating the ribbons. Send this Microsoft Project file to each of your PMs and instruct them to allow Microsoft Project to run macros in the project. After the macro runs and updates the ribbons, the user could close and discard the project.

That would be a "one and done" approach, but of course, it assumes you will not need to update the ribbons with any changes after the initial round of updating. Just an additional thought for you. Hope this helps.
Thank you for responding.

Unfortunately we only use Project Desktop and don't have access to Project Online or Server so enterprise options won't work for us. I did put Auto_Open into the local global.mpt file but it didn't run when launching project.

I do have a separate file with a macro that installs the ribbons so that part is covered.
But MS Project removes some of my ribbon formatting between sessions, so I thought if there was something that runs are startup I might be able to reinstate the formatting each session (testing would be required to see if it would work). Asking the PMs to run this file once every time they start Project probably won't fly, so we may need to live with the lost formatting. :(


I confess, I did read your post when it first appeared. I didn't respond because you asked if there was anything besides the Auto_Open Even and wasn't aware of anything but then my range of knowledge is limited to VBA. I probably should have responded by saying there might be an API that could do what you want but you'd have to do some research for that.


I do recall a previous post on this forum that is related to what you are trying to do. I'm not sure if it will help but you could give it a read.


If I may ask, can you show us the code you have that installs the ribbon? And which formatting is getting whacked?


One more thought popped into my mind after posting this. Years ago when I was in a corporate environment I customized the Project Global to include a series of macros (via custom icons). I hoped corporate would allow us to instill that customization into what was then the "base Global" used by all Project users but they didn't buy it so I ended up distributing the custom Global to all Project users in our group. This is along the same line that Dale proposed in his updated suggestion. As he said, just a thought.



I won't actually provide all the code but here are key parts

I use the following to get to the CustomUI file
strFN=Environ("LocalAppData") & "\Microsoft\Office\MSProject.officeUI"
If the file does not exist then my code creates it.

I then treat this file as a simple text file, scan it to an appropriate place, and then insert my own xml code in for the new ribbons I'm adding such as
Print #intOutfile, "<mso:tab id=""MyTab"" label=""New Tab"">"
Print #intOutfile, "<mso:group id=""MyGroup"" label=""New Group"">"
Print #intOutfile, "<mso:control idQ=""mso:ChangeWorkingTime"" size=””small”” visible=""true""/>"
Print #intOutfile, "<mso:control idQ=""mso:TaskOutdent"" size=””small”” visible=""true""/>"
Print #intOutfile, "<mso:control idQ=""mso:TaskIndent"" size=””small”” visible=""true""/>"
Print #intOutfile, "</mso:group>"
Print #intOutfile, "</mso:tab>"

Between MS Project sessions it appeared that MS Project was rewriting the MSProject.officeUI file to add autoScale to the group and remove the size from the control such as
<mso:group id="MyGroup" label="New Group" autoScale="true">
<mso:control idQ="mso:TaskIndent" visible="true"/>"

Now this is where I need to apologise.
It has been some time since I last thought about this issue and I thought using an AutoExec style macro might help to rewrite the ribbon when MS Project starts. Hence the reason for my original post.
However, in the intervening time project has been patched a couple of times and it now appears that MS Project is not removing the formatting.

So I'm still curious as so methods of running code on starting MS Project (desktop version) but as far as the specific formatting problem I was having, that has been solved.

Thank you all for your assistance.


Thanks for the update. I'm glad to hear the "overwrite" issue you were experiencing is apparently resolved but as far as other methods of running code, I can't help beyond what I already posted. I've never tried to edit XML for Project's ribbon UI so it is new territory for me also. Perhaps, but not likely, someone else with some expertise in that area will pop in.