PDA

View Full Version : Distributing MSP Macro



SeanS
01-25-2005, 08:41 AM
oI have a one-off macro that needs to be run by a number of users to rename a number of resources on their resource sheet in Microsoft Project.

Any ideas how I could distribute this to my users for them to run? I wouldn't want them doing a copy/paste into VBE or importing a VBA module into their project file.

Thanks, Sean.

Jacob Hilderbrand
01-25-2005, 08:54 AM
You can make the code in VB Script so they just run the file like an exe.

Just put the code into a text document and save it with a .vbs extension.

SeanS
01-25-2005, 09:04 AM
How do I actually get this to run DRJ?? Below is the code in my project vba module - are you saying just copy this into a text file and save it with a .vbs extension??

Sub ReplaceName()
ViewApply Name:="Resource Sheet"
Replace Field:="Name", Test:="contains", Value:="project manager", _
Replacement:="project manager IT", ReplaceAll:=True, Next:=True, _
MatchCase:=False
End Sub

Sorry for being a bit dumb, but I haven't done any VB scripting before, just plain old VB for Excel.

Thank, Sean.

Jacob Hilderbrand
01-25-2005, 09:14 AM
Well the code can be put into a text file then SaveAs, select All Files as the type and save with the .vbs extension. But the code will need to be modified. You need to specify what file to open etc.

SeanS
01-27-2005, 03:53 AM
Cheers DRJ - Nearly done what I need to do. The below works in terms of opening up the MSP file, but when I add in the ViewApply statment I get an error saying 'Expected statement'.

The statement works when run in MS Project itself.

Any ideas. Sean.

Dim objMSP
Set objMSP = WScript.CreateObject("MSProject.Application")
objMSP.Visible = TRUE
objMSP.FileOpen "C:\Documents and Settings\Desktop\Project1.mpp"
objMSP.ViewApply Name:="Resource Sheet"
objMSP.Replace Field:="Name", Test:="contains", Value:="project manager", _
Replacement:="project manager IT", ReplaceAll:=True, Next:=True, _
MatchCase:=False