How to list check-out versions


If your organization routinely performs reconciles on versions in the master database, it is useful to know whether or not a version is associated with an active check-out. This code can be run as a macro in ArcMap to list the active check-out versions.

How to use

  1. Paste the code into VBA in ArcMap.
  2. Click the source tab in the TOC, then click the master workspace.
  3. Run the List_CO_Versions sub and the check-out versions are listed in the immeadiate window in VBA.
[VBA]
Public Sub List_CO_Versions()
    
    Dim pMXD As IMxDocument
    Dim pWkSp As IWorkspace
    Dim pVerWkSp As IVersionedWorkspace
    Dim pEVerInfo As IEnumVersionInfo
    Dim pVerInfo As IVersionInfo
    Dim bolIsCO As Boolean
    Set pMXD = ThisDocument
    Set pWkSp = pMXD.SelectedItem
    
    ' Test each version to see if it is a check-out version
    If TypeOf pWkSp Is IVersionedWorkspace Then
        Set pVerWkSp = pWkSp
        Set pEVerInfo = pVerWkSp.Versions
        pEVerInfo.Reset
        Set pVerInfo = pEVerInfo.Next
        Do Until pVerInfo Is Nothing
            bolIsCO = IsCoVersion(pVerInfo.VersionName, pWkSp)
            If bolIsCO Then Debug.Print pVerInfo.VersionName & " is a checkout version"
            Set pVerInfo = pEVerInfo.Next
        Loop
    End If
    
End Sub

'++ Returns True if the version is a check-out version
'++ otherwise, returns false

Private Function IsCoVersion(strVersion As String, pWkSpRep As IWorkspaceReplicas) As Boolean
    
    Dim pRep As IReplica
    Dim pEnumRep As IEnumReplica
    Dim strUser As String
    Dim strDB As String
    Dim strCoVersion As String
    Dim pSQLSyntax As ISQLSyntax
    
    IsCoVersion = False
    
    '++ See if the version name matches a checkout version
    Set pSQLSyntax = pWkSpRep
    Set pEnumRep = pWkSpRep.Replicas
    pEnumRep.Reset
    Set pRep = pEnumRep.Next
    Do Until pRep Is Nothing
        If pRep.ReplicaRole = esriCheckOutTypeParent Then
            '++ Full qualify the version name from the checkout
            strCoVersion = pSQLSyntax.QualifyTableName("", pRep.Owner, pRep.Version)
            If UCase(strVersion) = UCase(strCoVersion) Then
                IsCoVersion = True
            End If
        End If
        Set pRep = pEnumRep.Next
    Loop
    
End Function