Original User: thaviti
Following code may help u.
Sub GetLayerNames()
Dim s As String
Dim aLayer As ILayer
Dim a, c As String
Dim pMxdoc As IMxDocument
Set pMxdoc = Application.Document
Dim pMap As IMap
Set pMap = pMxdoc.FocusMap
Dim b As String
b = pMap.Name + ":"
Dim pEnumLayer As IEnumLayer
Dim pId As New UID
Dim pparentlayer As ILayer
Dim coll As New Collection
Dim out As Variant
Set pEnumLayer = pMap.Layers(Nothing, False)
Set aLayer = pEnumLayer.Next
Dim parentLayerName As String
Do Until aLayer Is Nothing
coll.Add b & aLayer.Name
If (TypeOf aLayer Is IGroupLayer) Then
AddLayerNames aLayer, b & ":" & aLayer.Name, coll
End If
Set aLayer = pEnumLayer.Next
Loop
For Each out In coll
List = List & out & vbNewLine
Next
MsgBox b & Chr(13) & List
End Sub
Sub AddLayerNames(pGroupLayer As IGroupLayer, pGroupLayerFullName As String, ByRef collectionVariable As Collection)
If pGroupLayer Is Nothing Then Exit Sub
Dim compLayer As ICompositeLayer
Set compLayer = pGroupLayer
Dim childLayer As ILayer
Dim i As Integer
For i = 0 To compLayer.count - 1
Set childLayer = compLayer.Layer(i)
collectionVariable.Add pGroupLayerFullName & ":" & childLayer.Name
If TypeOf childLayer Is IGroupLayer Then
AddLayerNames childLayer, pGroupLayerFullName & ":" & childLayer.Name, collectionVariable
End If
Next
End Sub