Free Code

  • List Layers in TOC and featureclasses:
    Open VBA Editor and paste the following code in This.Document. -> then Run. (results will be in Output window) Please see our disclaimer.

    // Provided by 39 DEGREES NORTH, LLC
    // www.39dn.com

    Sub ListLayers()
       Dim pMxDoc As IMxDocument
       Set pMxDoc = ThisDocument
       Dim pMap As IMap
       Set pMap = pMxDoc.FocusMap

       Dim i As Long

       For i = 0 To pMap.LayerCount - 1
         Dim pLayer As ILayer
         Set pLayer = pMap.Layer(i)
         If TypeOf pLayer Is IFeatureLayer Then
           Dim pFeatLayer As IFeatureLayer
           Set pFeatLayer = pLayer
           Dim pDataset As IDataset
           Set pDataset = pFeatLayer.FeatureClass

           Debug.Print pLayer.Name & " -> " & pDataset.Name
         End If

       Next i
    End Sub

Products and Services

FREE Resources

Partnerships