MSP 2010 - Global Replacement of Resources in a Project

M

Michael Clark

I have created a comprehensive Project template that fits my organization almost perfectly. The resources I have assinged to each task are actually the ROLES that need to be assigned to the task. For example, on task such as INSTALL WINDOWS 2008 SERVER OS I have assigned the <WINDOWS ADMIN> because there are a number of these resources within the group and I need to assign the next one in line when the project is created.

There are a number of tasks where <WINDOWS ADMIN> appears as one of the resources. I am looking for a VBA macro the will allow me to globally change <WINDOWS ADMIN> for John Doe (both are listed on the Resource Sheet). I have tried simply Find/Replace but all that happens in the Resource Name column gets changed and a new resource of John Doe (a repeat) is added to the Resource Sheet.

Is there such a macro in existance or can anyone offer some advice on writing one? I've been looking at both the Tasks and Resources objects and find a great deal of cross-referencing between them. At first blush it appears that trying to walk either object (or both?) and just do a global replace of properties could/would get pretty messy. I've been using Rod Gill's 2010 version of VBA Programming and it's helping me locate the pieces I need but I suspect this is tougher than it looks.

Would appreciate any help anyone can offer.

Thank you...
 
M

Michael Clark

BTW...I have looked into the built-in Resource Replacement Tool and it does do what I need it to do except it makes me replace resources one task at a time. I'm looking for this exact functionality but with a Replace All option that covers the entire project.

Thanks again...:)
 
M

Michael Clark

Ok, making progress. I recorded a macro of replacing a resource on a task using the Resource Assignment tool. This rendered a nice piece of code that handled the replacement on a single task. I managed to modify the SelectTaskField command to expand to all Resource Names for all tasks and then let it do a global replace.

It mostly works. There are a couple of tasks where the new resource was inserted leaving the old one assigned. Don't know why that would be but at least I'm getting somewhere.

ViewApplyEx Name:="&Gantt Chart", ApplyTo:=0

txtFrom = AssignedResource.Value
txtTo = AvailableResource.Value
TaskCount = ThisProject.Tasks.Count

SelectTaskField Row:=0, Column:="Resource Names", Height:=TaskCount
ResourceAssignment Resources:=txtFrom, Operation:=pjReplace, With:=txtTo

BTW: the To and From variables are fed by a couple of ComboBoxes on a form I created. These are populated from the task sheet giving me a list of currently assigned resources (Work > 0) and another list of all resources. Code below:

Dim Res As Resource
Dim Prj As Project

Set Prj = ActiveProject

' Walk the Resource Sheet and load both controls
' AvailableResource gets an entry for each non-blank entry in the resource sheet
' AssignedResource gets an entry for every resource where .Work > 0

For Each Res In Prj.Resources
If Not Res Is Nothing Then
AvailableResource.AddItem Res.Name
If Res.Work > 0 Then
AssignedResource.AddItem Res.Name
End If
End If
Next Res

Feel free to use this if you like. If you make any nifty improvements please share them with the rest of the class...:)

Mike
 

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