1
votes

Within MS Project I'm handling different levels of tasks and subtasks. As I have a long list I would be able to setup a personalized Unique ID for each one of them based on their parent taks and grandparent task.

My outline levels are:

  • Lot (LO)
    • Phase (PH)
      • Category (CA)
        • Chapter (CH)
          • Deliverable (DE)
            • Task (TA)

At the end, I would like to have a reference in each line such as: LO1.PH01.CA01.CH01.DE01.TA01 (for the first task in the first Deliverable in the first Chapter .... and so on The second task in the same deliverable should be: LO1.PH01.CA1.CH1.DE1.TA2 The line of the parent level (Deliverable)should look lie: LO1.PH01.CA01.CH01.DE01.TAOO as some deliverables have no tasks assigned yet.

Would there be an automated way (VBA code or custom field function) to determine that reference and also to check that it is indeed unique?

Thanks a lot in advance for any help on this!

Regards,

Fabien PS: The outline levels provided by MSP are not always aligned between each "Lot" as in some "Lot" I don't have the "Category CA" level. In other words, the deliverable is not always on outline level 5.

1
Actually this can be achived with defining the WBS code within MS Project and using this.INOPIAE

1 Answers

0
votes

You need a recursive function which accepts a Task object and a string identifier. Given that you do not want to update the name property of the task, I would use the Notes property to store the identifier.

Option Explicit
Public Sub RecurseStart()

Dim taskeach As Task
Dim lngcount As Long

For Each taskeach In ThisProject.Tasks
    lngcount = lngcount + 1
    If taskeach.OutlineLevel = 1 Then
        TaskID taskeach, Right(taskeach.Name, 2) & lngcount
    End If
Next taskeach

End Sub

Public Sub TaskID(sometask As Task, someid As String)

Dim subtask As Task
Dim lngcount As Long
Dim someotherid As String

For Each subtask In sometask.OutlineChildren
    someotherid = someid & "."
    lngcount = lngcount + 1
    someotherid = someotherid & Right(subtask.Name, 2) & lngcount
    If subtask.OutlineChildren.Count <> 0 Then
        TaskID subtask, someotherid
    End If
    subtask.Notes = someotherid
    someotherid = someid
Next
End Sub