Determining MS Project Task Lineage
-
20-08-2019 - |
Question
I have a MS Project file which I am using the Primary Interop Assemblies to parse. How can I determine the lineage of a task? I was relying on the WBS code, however the client has started to fiddle with this field and it no longer represents the hierarchy of the data.
Edit: By lineage I mean a way to identify where in the hierarchy the task exists. By default the WBS code mimics this perfectly.
I need this information to determine what is the parent for a task.
Example
- A
- B
- B1
- B2
- B3
- C
The Lineage for B3 would be 2.3 (If we counted by 1, like project)
Solution
Try the Task object's OutlineNumber property and the PredecessorTasks collection.
HTM
Colby Africa
OTHER TIPS
Use 'OutlineChildren' property:
// from caller:
ListTasks(prj.OutlineChildren, "");
void ListTasks(Tasks lst, string indent)
{
foreach (Microsoft.Office.Interop.MSProject.Task t in lst) {
Log(indent + t.Start + " - " + t.Name);
ListTasks(t.OutlineChildren, indent + " ");
}
}
It creates indented tree of tasks.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow