I am exporting a ms xml from Primavera P6 and importing it in MS Project. I know the number of relationships in Primavera. But I am not sure if all the relationships are getting imported it MSP. Can anyone please tell a way to find the number of relationship in a MS Project . Please suggest
Asked
Active
Viewed 647 times
2 Answers
2
Yes - if you run the following code on your project, it will produce a dialogue box stating how many dependencies have been defined in the project:
Sub CountDependencies()
Dim i_RelationshipCount As Integer
Dim tsk As Task
Dim tsk_dep As TaskDependency
i_RelationshipCount = 0
For Each tsk In ActiveProject.Tasks
If tsk Is Nothing Then GoTo NextTask
For Each tsk_dep In tsk.TaskDependencies
'only count predecessors (otherwsie will count each realtionship twice)
If tsk_dep.To = tsk Then
i_RelationshipCount = i_RelationshipCount + 1
End If
Next tsk_dep
NextTask:
Next tsk
MsgBox i_RelationshipCount & " dependencies/relationships exist in this schedule."
End Sub

Andrew - Eversight Ltd
- 347
- 1
- 4
2
@AndrewEversight's answer is totally correct. FWIW: Here's a smaller routine to give you the same result:
Sub CountDependencies()
Dim i_RelationshipCount As Integer
Dim tsk As Task
i_RelationshipCount = 0
For Each tsk In ActiveProject.Tasks
If Not tsk Is Nothing Then
i_RelationshipCount = i_RelationshipCount + tsk.PredecessorTasks.Count
End If
Next tsk
MsgBox i_RelationshipCount & " dependencies/relationships exist in this schedule."
End Sub

Rachel Hettinger
- 7,927
- 2
- 21
- 31