for intX = 0 to pMap.layercount -1
if pmap.layer(intx).name = combobox1.value then
'call modified dev sample
OpenWindow(pmap.layer(intx))
exit sub
end if
next
'if not a layer try the tables
dim pSTColl as iStandaloneTableCollection
set pstcoll = pmap
for intx = 0 to pstcoll.StandaloneTableCount -1
if pstcoll.standaloneTable(intx).name = combobox1.value then
openWindow(pstcoll.standaloneTable(intx))
exit sub
endif
next
'if could not find either a layer or table...
msgbox("couldn't find it")
exit sub
'modified vba sample from Dev Help
Private Sub OpenWindow(pUnknown as IUnknown)
Dim pMxDoc As IMxDocument
Dim pLayer As ILayer
Dim pStandaloneTable As IStandaloneTable
Dim pTableWindow2 As ITableWindow2
Dim pExistingTableWindow As ITableWindow
Dim SetProperties As Boolean
'Get the selected item from the current contents view
Set pMxDoc = ThisDocument
Set pTableWindow2 = New TableWindow
' Determine the selected item's type
' Exit sub if item is not a feature layer or standalone table
If TypeOf pUnknown Is IFeatureLayer Then 'A FeatureLayer
Set pLayer = pUnknown
Set pExistingTableWindow = _
pTableWindow2.FindViaLayer(pLayer)
' Check if a table already exists; if not create one
If pExistingTableWindow Is Nothing Then
Set pTableWindow2.Layer = pLayer
SetProperties = True
End If
ElseIf TypeOf pUnknown Is IStandaloneTable Then
' A standalone table
Set pStandaloneTable = pUnknown
Set pExistingTableWindow = _
pTableWindow2.FindViaStandaloneTable(pStandaloneTable)
' Check if a table already exists; if not, create one
If pExistingTableWindow Is Nothing Then
Set pTableWindow2.StandaloneTable = pStandaloneTable
SetProperties = True
End If
End If
If SetProperties Then
pTableWindow2.TableSelectionAction = esriSelectFeatures
pTableWindow2.ShowSelected = False
pTableWindow2.ShowAliasNamesInColumnHeadings = True
Set pTableWindow2.Application = Application
Else
Set pTableWindow2 = pExistingTableWindow
End If
' Ensure Table Is Visible
If Not pTableWindow2.IsVisible Then pTableWindow2.Show True
End Sub