Search code examples
ms-projectprimavera

count relationship in microsoft project


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


Solution

  • 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