Distributing a Project 2003 Macro

J

Jeff

All,

I have a macro that consists of a module and form that is part of my
Global.MPT. As well, I have added a menu item that calls this macro.
All works well.

I am charged with distributing this macro to others around the company.
I have a Digital Signature and have signed the macro. Here is where I
am stumped.

1) How can I easily distribute this macro?
2) Is there a method for automating the menu item to point to this
macro?

Thanks for any help!
Jeff
 
J

JackD

Write code to copy the toolbar and the module containing the macro to the
global.mpt file. The easiest way to do this is to turn on the macro recorder
then use the organizer to copy the stuff over.

After that, put the module and toolbar in an empty file and use Project_Open
to run the code which copies things over.
You can email the file to people and have them open that file and let it run
and it should do what you want.

For details about project_open look here:
http://masamiki.com/project/project_open.htm
 
J

Jeff

Thanks Jack for your reply.

I am familiar with the Project_Open method, and have tried to use the
recording feature to organize the macros. The recorder only comes up
with

Sub Macro1()
' Macro Macro1
MacroShowVba
End Sub

and none of the organization I did. Any thoughts?

Thanks,
Jeff
 
J

Jan

Hi Jeff,

Please find an example which you should customize to your own needs:
Private Sub Project_Open(ByVal pj As MSProject.Project)
If MsgBox("This macro will make modification to your GLOBAL.MPT file. Do
you wish to proceed", vbOKCancel, "Modifying Global.mpt") = vbOK Then
If MsgBox("Do you want to install the Toolbar?", vbYesNo, _
"Install ...... Function") = vbYes Then
OrganizerMoveItem Type:=pjModules, FileName:="<your file>.mpp",
ToFileName:="GLOBAL.MPT", name:="VacationCalendar"
OrganizerMoveItem Type:=pjToolbars, FileName:="<your file>.mpp",
ToFileName:="GLOBAL.MPT", name:="Create Vacation Calendar"
OrganizerMoveItem Type:=pjModules, FileName:="<your file>.mpp",
ToFileName:="GLOBAL.MPT", name:="TestForm"
CommandBars("<your toolbar>").Visible = True
MsgBox "....... Toolbar has been installed", 64, "Install .....
Function"
FileClose Save:=False
End If
End If
End Sub

As Jack said, make sure that you have a separate MPP-file which only
contains the customized code above and the toolbar you want to distribute

Cheers,

Jan
 
J

JackD

Thanks Jan,

Don't forget the the line wrap. Each command should be on a single line or
use the continuation character _ like the If MsgBox line does.
 
J

Jeff

Thanks Jan/Jack,

Where would be without the internet! You both have saved me hour of
work and lots of hair!

My macro looks like this:

Private Sub Project_Open(ByVal pj As MSProject.Project)
installMacros
End Sub

Public Sub installMacros()
If MsgBox("This macro will make modification to your GLOBAL.MPT
file. Do you wish to proceed", _
vbOKCancel, "Modifying Global.mpt") =
vbOK Then
OrganizerMoveItem Type:=pjModules, FileName:="ProjectInfo Macro
Installation.mpp", _
ToFileName:="GLOBAL.MPT",
Name:="ProjectInformation"
OrganizerMoveItem Type:=pjModules, FileName:="ProjectInfo Macro
Installation.mpp", _
ToFileName:="GLOBAL.MPT",
Name:="frmProjectInformation"
Dim cnt As Integer
cnt = CommandBars("Project").Controls.Count + 1
CommandBars("Project").Controls.Add Type:=msoControlButton,
ID:=40001, _
Before:=cnt, Parameter:="Macro
""ProjectInformation"""
Set cbar1 = CommandBars("Project").Controls.Item(cnt)
cbar1.Caption = "Custom Information.."
MsgBox "Completed"
FileClose Save:=False
End If
End Sub

It does what it is supposed to do, it installs the new form and module,
then creates a new menu entry on the Project Bar. FYI, the form
contains an imbedded IE object that points to an intranet site passing
the project id. The intranet site contains HR type info like project
manager, division etc. This takes advantage of the HR info already
there, rather than keeping enterprise codes up to date. Works well.

The only thing that doesn't seem to work is the Project_Open event. It
doesn't fire when the project is opened. It's not too big of deal, but
if you have any insite into why that would be great.

Thanks again!!!
Jeff
 
E

egun

Jeff,

My totally amateur guess would be macro security. Try turning the security
level to low before you open the file, and see what happens.

Eric
 
J

Jan

Jeff,

I agree to Eric's comments. Make sure that macro's are enabled.

BTW. I am curious how you were able to invoke the IE stuff in your macro.

Cheers,

Jan
 

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