HOW TO
This article shows how to loop through all the tables in the first data frame in ArcMap. The table names will be displayed in a series of message boxes.
Note:
Code in ThisDocument code module will only run in the current map document. To store the code in all map documents, open the code in the Normal.mxt ThisDocument code module.
Code:
Sub GetTables()
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
'Get the tables in the first data frame
Dim pTc As ITableCollection
Set pTc = pDoc.FocusMap
Dim pTable As ITable
'Loop through the tables
Dim pDs As IDataset
For i = 0 To pTc.TableCount - 1
Set pTable = pTc.Table(i)
'Get the table's name
Set pDs = pTable
MsgBox pDs.Name
Next i
End Sub
Article ID:000004954
Get help from ArcGIS experts
Download the Esri Support App