MS Project 2013: display resources on summary tasks

前端 未结 2 1547
情歌与酒
情歌与酒 2021-01-16 20:49

Is there a way to configure MS Project 2013 so that it displays in a resource column (eg, resource initials) of the Gantt Chart view of summary tasks the UNION of all resou

2条回答
  •  被撕碎了的回忆
    2021-01-16 21:09

    Those resource fields exist at the summary level because you can directly assign resources to a summary task, so you can't use those fields for this purpose. However, here's a macro that aggregates the names of the resources assigned to the subtasks. The results are put in Text1 at the summary level. You can then modify the Gantt chart bar styles to show that text field.

    Sub RollupResourceNames()
    
        Dim tsk As Task
        Dim list As String
        Dim key As Variant
    
        For Each tsk In ActiveProject.Tasks
            If tsk.Summary Then
                Dim col As New Collection
                Set col = GetChildResourceAssignments(tsk)
                list = vbNullString
                For Each key In col
                    list = list & ", " & key
                Next
                If Len(list) > 2 Then
                    list = Mid$(list, 3)
                End If
                tsk.Text1 = list
            End If
        Next tsk
    
    End Sub
    
    Function GetChildResourceAssignments(parent As Task) As Collection
    
        Dim col As New Collection
    
        Dim child As Task
        Dim asn As Assignment
        For Each child In parent.OutlineChildren
            If child.Summary Then
                Dim col2 As New Collection
                Set col2 = GetChildResourceAssignments(child)
                Dim key As Variant
                For Each key In col2
                    col.Add key, key
                Next key
            End If
            For Each asn In child.Assignments
                On Error Resume Next
                col.Add asn.Resource.Name, asn.Resource.Name
                On Error GoTo 0
            Next asn
        Next child
    
        Set GetChildResourceAssignments = col
    
    End Function
    

提交回复
热议问题