Here’s probably one of the most interesting new features (well, other than reporting) added to the new Microsoft Project desktop client – the Task Path feature. This feature allows you to easily review a schedule to assess the impact of a single task.
First off, I point out that fellow MVP Nenad Trajkovski has already posted on this topic. I wanted to add to his post, and perhaps provide some additional information on how to consume this new feature in the updated Project VBA object model.
In the screenshot above, you see that I have selected a single task. Each of the driving predecessors of the task are highlighted in orange. In turn, the driven successors of the task are highlighted in purple.
This is all controlled through the Task Path interface, now found on the Gantt Chart Format tab.
Opening that dropdown, you see the options for the task path display. Note that these options are not mutually exclusive, i.e. I can actually select all of the options to add informational depth to my Gantt Chart display.
As always, just mouse over the bar in the Gantt Chart to see what the color represents – or doubleclick on the Gantt Chart to see the legend.
So that’s great, but what about if I want to filter on only those tasks that are predecessors and successors? There’s no field affiliated with that setting, so how can I determine which tasks are relevant?
Enter VBA. The new setting may be consumed via the VBA object model using:
For example, the following VBA code will label each task within the schedule as a Predecessor or Successor in the Text1 field, and then filter the view on only those tasks which have been flagged.
Sub DefinePath() Dim T As Task Dim I As Integer 'Clear the existing filter Application.FilterClear 'Capture the selected task I = Application.ActiveCell.Task.ID 'Flag the Predecessors and Successors For Each T In ActiveProject.Tasks T.Text1 = "" If T.ID = I Then T.Text1 = "Selected Task" End If If T.PathPredecessor = True Then T.Text1 = "Predecessor" End If If T.PathSuccessor = True Then T.Text1 = "Successor" End If Next T 'Apply a filter on the flagged tasks SetAutoFilter FieldName:="Text1", FilterType:=pjAutoFilterIn, _ Criteria1:="Predecessor" & Chr$(9) & "Successor" & Chr$(9) & "Selected Task" End Sub
Here’s what the results look like…