HOW TO
This article shows how to add a non-geodatabase Access table to ArcMap using VBA and ArcObjects.
Note:
Code in ThisDocument module will only run in the current map document. To store the code in all your map documents, open the Normal.mxt ThisDocument code module.
Code:
Sub AddTable()
' Get the table from the workspace factory
Dim pWf As IWorkspaceFactory
Set pWf = New AccessWorkspaceFactory
Dim pWs As IFeatureWorkspace
Set pWs = pWf.OpenFromFile("c:\incidents\February\DF\db2.mdb", 0)
Dim pTable As ITable
Set pTable = pWs.OpenTable("Dogs")
' Get a Standalone Table
Dim pStTable As IStandaloneTable
Set pStTable = New StandaloneTable
Set pStTable.Table = pTable
' Add the table to ArcMap
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
Dim pMap As IMap
Set pMap = pDoc.FocusMap
Dim pTc As IStandaloneTableCollection
Set pTc = pMap
pTc.AddStandaloneTable pStTable
' Refresh the View and Table of Contents
pDoc.ActiveView.Refresh
pDoc.UpdateContents
End Sub
Article ID:000004949
Get help from ArcGIS experts
Download the Esri Support App