パスが切れたデータ ソースの取得

Sub GetOriginalPath()
    'ThisDocumentの取得
    Dim pMxDocument As IMxDocument
    Set pMxDocument = ThisDocument
    
    'アクティブなデータフレームの取得
    Dim pMap As IMap
    Set pMap = pMxDocument.FocusMap
    
    '最上位レイヤの取得
    Dim pLayer As IDataLayer
    Set pLayer = pMap.Layer(0)
    
    Dim pDatasetName As IDatasetName
    Set pDatasetName = pLayer.DataSourceName

    Debug.Print pDatasetName.WorkspaceName.PathName
End Sub