I am currently trying to write a VBA code that will look at a project plan and delete all of the tasks that have zero work effort, but are not a milestone, from my plan. We have added a custom field called Key Milestone to capture whether a task is a milestone or not. The reason we are not using the existing Milestone field is that not all of the tasks with zero work effort and zero duration are necessarily milestones.
I was previously unfamiliar with the GetField function in VBA and I have been working through a couple of tries at incorporating this to 'read' the custom field as a part of this code. Here is what I have so far:
Sub DeleteMsProjectTask()
Dim proj As Project
Dim t As Task
Set proj = ActiveProject
For Each t In proj.Tasks
If t.OutlineLevel > 1 And t.Work = 0 Then
If GetField(FieldNametoFieldConstant("Key Milestone") = Yes Then
Else
t.Delete
End If
End If
Next t
End Sub
This is not working as it doesn't read the milestone field correctly. Thanks in advance for the help!