HOW TO
This article contains a code sample that shows how to get the full path of a layer using VBA.
Note:
Code in the Project's ThisDocument code module will only run in the current map document. If you want to store the code in all your map documents open the Normal.mxt ThisDocument code module instead.
Code:
Sub GetLayerPath()
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
'Get the first map in the document
Dim pMap As IMap
Set pMap = pDoc.FocusMap
'Get the first layer in the map
Dim pLayer As IFeatureLayer
Set pLayer = pMap.Layer(0)
'Get the feature class for the first layer
Dim pFc As IFeatureClass
Set pFc = pLayer.FeatureClass
'Gets the dataset for standalone feature class
Dim pDataset As IDataset
Set pDataset = pFc
Dim pWorkspace As IWorkspace
Set pWorkspace = pDataset.Workspace
Debug.Print pWorkspace.PathName
End Sub
Article ID:000004948
Get help from ArcGIS experts
Download the Esri Support App