I am using MS Project to list all the projects and work my department is doing. I have created custom fields (Text 1(proj name)
and Text 2 (proj number)
) in my Gantt Chart view for each task and subtask. How can I create a macro to get these to show up in my Resource Usage view with all the data I entered in at the Gantt Chart view? I want to see a list of all my resources, what tasks that they are assigned to and see those custom fields for each of those tasks. Thank you.
2 Answers
There are two sets of custom fields against assignments. Resource.assignments and task.assignments.
If you reference the assignments via the tasks collection in VBA or the task usage view in the client you'll be updating the task.assignment field.
If you access the assignment via the resources collection or the resource usage view, then it's the resource.assignments field you're updating.
If you want them both to align, you need a routine that steps through all the tasks, then each assignment for each task, then locate the same assignment via the resources collection, and set task.assignments.text21 = resources.assignments.text21 (for example).
This was introduced in 2007 i think - not viewed as a bug by Microsoft, just a new feature.
The "task" data you see in the Resource Usage view and the "resource" data you see in the Task Usage view are actually the Assignment data.
UPDATE
Thanks to @Andrew's clarification on the two sets of custom text fields for assignments, I've updated the code so that the task's Text1 field is visible in both the Task Usage view and the Resource Usage view.
Here's a macro that updates the Assignment Text1 field with the task's Text1 field:
Sub UpdateAssignmentInfo()
Dim tsk As Task
Dim asn As Assignment
For Each tsk In ActiveProject.Tasks
For Each asn In tsk.Assignments
asn.Text1 = tsk.Text1
Next asn
Next tsk
Dim res As Resource
For Each res In ActiveProject.Resources
For Each asn In res.Assignments
asn.Text1 = asn.Task.Text1
Next asn
Next res
End Sub