P
Paul Conroy
The macro below adds the parent summary task to a task/text custom field
called "Parent Summary" {I suggest you add it to the beforesave event in the
Ent.Global}
Apologies to all VBA experts for being such a hack, please feel free to
optimise this code. I'd welcome any comments.
In my lab environment, I can add the CF "Parent Summary" to the my task
view, however it always returns a null value. I'd be interested in how this
manifests in other environments.
Dim t As Task
Dim t1 As Task
Dim pos As Integer
Dim myflag As Integer
Dim counter As Integer
Dim parentwbs As String
Dim parenttaskname As String
For Each t In ActiveProject.Tasks
'check that task is not nothing
If Not t Is Nothing Then
'find the last period in the wbs code
counter = 1
Do While counter < Len(t.WBS)
If InStr(counter, t.WBS, "1", 1) <> 0 Then
myflag = InStr(counter, t.WBS, ".", 1)
End If
counter = counter + 1
Loop
If myflag > 1 Then myflag = myflag - 1
'search for parent wbs value
parentwbs = Left(t.WBS, myflag)
For Each t1 In ActiveProject.Tasks
If Not t1 Is Nothing Then
If t1.WBS = parentwbs Then parenttaskname = t.Name
End If
Next
'set custom field to parent summary task name
If parenttaskname = "" Then parenttaskname = ActiveProject.Name
Call t.SetField(FieldNameToFieldConstant("Parent Summary"),
parenttaskname)
End If
Next
called "Parent Summary" {I suggest you add it to the beforesave event in the
Ent.Global}
Apologies to all VBA experts for being such a hack, please feel free to
optimise this code. I'd welcome any comments.
In my lab environment, I can add the CF "Parent Summary" to the my task
view, however it always returns a null value. I'd be interested in how this
manifests in other environments.
Dim t As Task
Dim t1 As Task
Dim pos As Integer
Dim myflag As Integer
Dim counter As Integer
Dim parentwbs As String
Dim parenttaskname As String
For Each t In ActiveProject.Tasks
'check that task is not nothing
If Not t Is Nothing Then
'find the last period in the wbs code
counter = 1
Do While counter < Len(t.WBS)
If InStr(counter, t.WBS, "1", 1) <> 0 Then
myflag = InStr(counter, t.WBS, ".", 1)
End If
counter = counter + 1
Loop
If myflag > 1 Then myflag = myflag - 1
'search for parent wbs value
parentwbs = Left(t.WBS, myflag)
For Each t1 In ActiveProject.Tasks
If Not t1 Is Nothing Then
If t1.WBS = parentwbs Then parenttaskname = t.Name
End If
Next
'set custom field to parent summary task name
If parenttaskname = "" Then parenttaskname = ActiveProject.Name
Call t.SetField(FieldNameToFieldConstant("Parent Summary"),
parenttaskname)
End If
Next