none
Resource Usage view: Custom field to view the overall path/WBS for each task RRS feed

  • Question

  • Hello,

    I am looking to build a custom field that allows to view the overall WBS hierarchy of each tasks...

    I am working with 2010 and it has a built in field (Task Summary Name) that tells me the name of the task 1 level up the WBS... you would understand that with many level in the WBS, this info is not relevant...

    Is there any way to customise/VBA code or anything else a custom field in order to show the overall WBS???

    Example:

    1 Summary A

    1.1 Summary A.1

    1.1.1 Summary A.1.X

    1.1.1.1 Summary A.1.X.!

    1.1.1.1.1 Task zyx

    in a typical Resource Usage view I would have:

    Resource Name Task Name Summary Task

    Bob Task zyx Summary A.1.X.!

    What I would like to achieve is:

    Resource Name  Task Name Summary Task Overall Path (Custom Field - Text 1)

    Bob      Task zyx Summary A.1.X.! Summary A -> Summary A.1 -> Summary A.1.X -> Summary A.1.X.!


    is there anyone who can help to do the "magic"? ;)

    Many thanks

    Regards

    Ivan

    Friday, February 26, 2016 7:07 AM

Answers

  • Sorry, I missed "Resource Usage view". With initial response, you have only path on task level field. To get it in resource field to be used in Resource Usage, use this one:

    Sub SetPath()
     Dim t As Task
     Dim aT As Task
     Dim r As Resource
     Dim a As Assignment
     Set t = ActiveProject.ProjectSummaryTask
     kids t
     
     For Each r In ActiveProject.Resources
        For Each a In r.Assignments
            Set aT = ActiveProject.Tasks(a.TaskID)
            a.Text2 = aT.Text2
        Next a
     Next r
     End Sub
    
     Sub kids(ByRef t As Task)
     Dim kid As Task
     If t.OutlineLevel = 1 Then
        t.Text2 = ""
     ElseIf t.OutlineLevel = 2 Then
        t.Text2 = t.OutlineParent.Name
     Else
        t.Text2 = t.OutlineParent.Text2 & "-" & t.OutlineParent.Name
     End If
     For Each kid In t.OutlineChildren
        kids kid
     Next kid
     End Sub

    Sorry!

    Regards
    Barbara


    To increase the value of this forum, please mark the replies that helped to solve your issue as answer. If you find answers to questions from other forum participants to be helpful, please mark them as helpful. Your participation will help others to find an appropriate solution faster. Thanks for your support!

    • Marked as answer by Ivan Pironi Monday, February 29, 2016 8:09 AM
    Friday, February 26, 2016 9:09 AM
    Moderator

All replies

  • Hi,

    I used http://zo-d.com/blog/archives/programming/recursion-in-project-vba.html as basic and use the following code.

    Sub SetPath()
     Dim t As Task
     Set t = ActiveProject.ProjectSummaryTask
     kids t
     End Sub
    
     Sub kids(ByRef t As Task)
     Dim kid As Task
     If t.OutlineLevel = 1 Then
        t.Text2 = ""
     ElseIf t.OutlineLevel = 2 Then
        t.Text2 = t.OutlineParent.Name
     Else
        t.Text2 = t.OutlineParent.Text2 & "-" & t.OutlineParent.Name
     End If
     For Each kid In t.OutlineChildren
        kids kid
     Next kid
     End Sub

    Does that help?

    Regards
    Barbara


    To increase the value of this forum, please mark the replies that helped to solve your issue as answer. If you find answers to questions from other forum participants to be helpful, please mark them as helpful. Your participation will help others to find an appropriate solution faster. Thanks for your support!

    Friday, February 26, 2016 8:48 AM
    Moderator
  • Sorry, I missed "Resource Usage view". With initial response, you have only path on task level field. To get it in resource field to be used in Resource Usage, use this one:

    Sub SetPath()
     Dim t As Task
     Dim aT As Task
     Dim r As Resource
     Dim a As Assignment
     Set t = ActiveProject.ProjectSummaryTask
     kids t
     
     For Each r In ActiveProject.Resources
        For Each a In r.Assignments
            Set aT = ActiveProject.Tasks(a.TaskID)
            a.Text2 = aT.Text2
        Next a
     Next r
     End Sub
    
     Sub kids(ByRef t As Task)
     Dim kid As Task
     If t.OutlineLevel = 1 Then
        t.Text2 = ""
     ElseIf t.OutlineLevel = 2 Then
        t.Text2 = t.OutlineParent.Name
     Else
        t.Text2 = t.OutlineParent.Text2 & "-" & t.OutlineParent.Name
     End If
     For Each kid In t.OutlineChildren
        kids kid
     Next kid
     End Sub

    Sorry!

    Regards
    Barbara


    To increase the value of this forum, please mark the replies that helped to solve your issue as answer. If you find answers to questions from other forum participants to be helpful, please mark them as helpful. Your participation will help others to find an appropriate solution faster. Thanks for your support!

    • Marked as answer by Ivan Pironi Monday, February 29, 2016 8:09 AM
    Friday, February 26, 2016 9:09 AM
    Moderator
  • Great! that is perfect!!!

    note a side for everyone: the code was breaking because the "string in Text2 was more than 256 character... just a small check (IF cycle) on the length did the job :)

    Monday, February 29, 2016 8:11 AM