Copying Macro to ThisProject

J

Jim Spiller

Say, I have the following macro:

Private Sub Project_Activate(ByVal pj As Project)
MsgBox "HI"
End Sub

I want this to run every time I open a New project and every time I open an
existing project. This appears to work by putting this code into the
ThisProject (Global.mpt).

My question is this:

Can I put this code into the ThisProject (Global.mpt) section automatically
using a Project_Open or Auto_Open macro when a setup file is opened? I can
move Modules into the Global.mpt by using OrganizerMoveItem but is there an
equivalent command for moving something to the ThisProject (Global.mpt)
area?

Or, is there another way to achieve this?

Thanks all!
 
R

Rod Gill

I think since 2007 Microsoft disabled ability to move code like this for
security reasons. All code in ThisProject has to be moved manually.

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




Jim Spiller said:
Say, I have the following macro:

Private Sub Project_Activate(ByVal pj As Project)
MsgBox "HI"
End Sub

I want this to run every time I open a New project and every time I open
an existing project. This appears to work by putting this code into the
ThisProject (Global.mpt).

My question is this:

Can I put this code into the ThisProject (Global.mpt) section
automatically using a Project_Open or Auto_Open macro when a setup file is
opened? I can move Modules into the Global.mpt by using OrganizerMoveItem
but is there an equivalent command for moving something to the ThisProject
(Global.mpt) area?

Or, is there another way to achieve this?

Thanks all!








__________ Information from ESET Smart Security, version of virus
signature database 5048 (20100421) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 5048 (20100421) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
R

Rod Gill

You know I can't remember, damn, another grey moment!

It may be that the ThisProject file always needed manually copying.

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




Jim Spiller said:
Thanks Rod... How would one do this is Project 2003?






__________ Information from ESET Smart Security, version of virus
signature database 5049 (20100422) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 5051 (20100422) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
J

Jim Spiller

Hey Rod,

Thanks for responding. I think you may be right about not being able to
automatically copy into ThisProject but wanted to check...

What we are really trying to do has to do with Project 2010. I'm working
this issue on the Proj 2010 groups too but thought I'd run it by the experts
here (I didn't see you hanging out over there Rod, so that's why I tried
this group<g>).

Here's the scoop if anyone with Project 2010 wishes to ponder the issue:

For all versions of Project prior to Project 2010, we invoke our tools from
within Project using a Toolbar Button assigned to a Macro. A user opens a
Project Setup file which contains an Auto_Open Macro which copies over the
Toolbar with the button and the Macro. A toolbar button is permanently added
to Project without the user needing to customize anything themselves.
Perfect.

Project 2010 now has Ribbons and no Toolbars. You can manually create a Tab
on this Ribbon with a Button assigned to a Macro but this is a manual
process, there is no way to automate this process. There is a way to
dynamically add a Ribbon in Project 2010 as described here:
http://msdn.microsoft.com/en-us/library/ee767705(office.14).aspx but
this can only be invoked when opening an existing file. It won't add a
button to the ribbon when opening the New project. The solution that we
thought might work best was if we could use the Project_Activate event in
ThisProject so a button on the Ribbon would appear constantly for all New
project and any existing projects. But alas, it doesn't appear that we can
automatically copy to ThisProject.

Make sense? All we want is a way for us to automate the process of adding a
Button to the Ribbon so the user doesn't have to...

Any ideas are greatly appreciated!

Jim
 

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