The other day I had a request from an internal customer that wanted to create deliverables for a large number of tasks that already existed in their project plan. They wanted to be able to simply flag each task as a deliverable and have it published. They did not want to do all the steps involved with creating a deliverable.
They also wanted to tightly couple the task name and dates with the deliverable name and dates. Currently, if a deliverable is linked to a task, when the task’s dates change, the dates for the deliverable do not. This is by design to allow the project manager to intentionally make the change to the deliverable dates since these dates are commonly published to a large audience. In this case, the user wanted the deliverable dates to change with the task dates with minimum user intervention.
To get started, I created a flag enterprise custom field. The custom field that I created was “Pub Deliverable” and it is a task custom field. I added the field to the Gantt Chart view in Project Professional:
Next, I wrote the following VBA macro:
Dim t As Task
Dim fPub As String
For Each t In ActiveProject.Tasks
‘ This gets the flag value from the Enterpise Custom Field
fPub = t.GetField(FieldNameToFieldConstant(“Pub Deliverable”))
If fPub = “Yes” Then
‘ If the task has this deliverable GUID, then there is no deliverable
If t.DeliverableGuid = “00000000-0000-0000-0000-000000000000” Then
DeliverableCreate t.Name, t.Start, t.Finish, t.Guid
DeliverableUpdate t.DeliverableGuid, t.Name, t.Start, t.Finish
If t.DeliverableGuid <> “00000000-0000-0000-0000-000000000000” Then
This macro loops through all the tasks. If the flag field “Pub Deliverable” is set to yes, then it either creates or updated the deliverable. If it is set to no and there is a deliverable associated with the task, the deliverable is deleted.
Before you can run this code, you will need to publish and create a workspace for your project. To run it, follow these steps:
1. Open your Project Plan
2. Press Alt+F11 – This will open the VBA Editor
4. Copy the VBA code into the Object
With this solution, the user can simply flag each task that they want published as a deliverable and run the macro. If you want to have this code executed regularly without user intervention, you might want to consider placing this code in an event handler (VBA Event Handler Example).