Option Explicit Sub Test() 'highlight the first layer's workspace in the Source contentsview Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument Dim pFLayer As IFeatureLayer Set pFLayer = FindLayer(pMxDoc.FocusMap, "MyLayer") If pFLayer Is Nothing Then MsgBox "layer not found" Exit Sub End If Dim pDS As IDataset Set pDS = pFLayer.FeatureClass Dim pCV As IContentsView Dim l As Long For l = 0 To pMxDoc.ContentsViewCount - 1 If pMxDoc.ContentsView(l).Name = "Source" Then Set pCV = pMxDoc.ContentsView(l) Exit For End If Next l If Not pCV Is Nothing Then Set pMxDoc.CurrentContentsView = pCV pCV.SelectedItem = pDS.Workspace End If End Sub Function FindLayer(pMap As IMap, s As String) As ILayer Set FindLayer = Nothing If pMap.LayerCount = 0 Then Exit Function End If Dim pEnumLayer As IEnumLayer Set pEnumLayer = pMap.Layers Dim pLayer As ILayer Set pLayer = pEnumLayer.Next Do Until pLayer Is Nothing If UCase(pLayer.Name) = UCase(s) Then Set FindLayer = pLayer Exit Do End If Set pLayer = pEnumLayer.Next Loop End Function
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.