Public
Sub
ShowLayerName()
' /显示当前Map中的图层
Dim pFeatureLayer As IFeatureLayer
Dim pLayer As ILayer
Dim pDocument As IMxDocument
Dim pMap As IMap
Set pDocument = ThisDocument
Set pMap = pDocument.FocusMap
Dim i As Long
For i = 0 To pMap.LayerCount - 1
' /用当前Map的图层对象实现相应的图层接口
' /如果只是为了显示图层名称,则IFeature或者ILayer接口都可以
' /实现IFeatureLayer接口
Set pFeatureLayer = pMap.Layer(i)
' /实现ILayer接口
Set pLayer = pMap.Layer(i)
Debug.Print pFeatureLayer.Name
Next
End Sub
Public Sub ShowLayerName1()
' /显示当前Map的图层
Dim pDocument As IMxDocument
Dim pMap As IMap
Set pDocument = ThisDocument
Set pMap = pDocument.FocusMap
Dim pLayers As IEnumLayer
' /实现IEnunLayer接口,类似于Collection
Set pLayers = pMap.Layers
' /以下是遍历这个Collection
' /实现显示所有图层的名称
Dim pFeatureLayer As IFeatureLayer
Set pFeatureLayer = pLayers.Next
While Not pFeatureLayer Is Nothing
Debug.Print pFeatureLayer.Name
Set pFeatureLayer = pLayers.Next
Wend
End Sub
' /显示当前Map中的图层
Dim pFeatureLayer As IFeatureLayer
Dim pLayer As ILayer
Dim pDocument As IMxDocument
Dim pMap As IMap
Set pDocument = ThisDocument
Set pMap = pDocument.FocusMap
Dim i As Long
For i = 0 To pMap.LayerCount - 1
' /用当前Map的图层对象实现相应的图层接口
' /如果只是为了显示图层名称,则IFeature或者ILayer接口都可以
' /实现IFeatureLayer接口
Set pFeatureLayer = pMap.Layer(i)
' /实现ILayer接口
Set pLayer = pMap.Layer(i)
Debug.Print pFeatureLayer.Name
Next
End Sub
Public Sub ShowLayerName1()
' /显示当前Map的图层
Dim pDocument As IMxDocument
Dim pMap As IMap
Set pDocument = ThisDocument
Set pMap = pDocument.FocusMap
Dim pLayers As IEnumLayer
' /实现IEnunLayer接口,类似于Collection
Set pLayers = pMap.Layers
' /以下是遍历这个Collection
' /实现显示所有图层的名称
Dim pFeatureLayer As IFeatureLayer
Set pFeatureLayer = pLayers.Next
While Not pFeatureLayer Is Nothing
Debug.Print pFeatureLayer.Name
Set pFeatureLayer = pLayers.Next
Wend
End Sub