HOW TO
Note: This article pertains to ArcGIS versions 8.x. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.
This VBA example illustrates how to add an ArcInfo annotation layer to ArcMap programmatically using ArcObjects.
Note: Support for Visual Basic for Applications (VBA) for ArcMap and ArcCatalog ended with the ArcGIS 10.2.2 release, and Esri has not included VBA compatibility setups since version 10.5. See: ArcGIS Desktop and VBA Moving Forward
Note: For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
'''This code loads an ArcInfo 7.x Annotation Coverage Dim a_wf As IWorkspaceFactory Set a_wf = New ArcInfoWorkspaceFactory Dim b_fc As IFeatureWorkspace Set b_fc = a_wf.OpenFromFile("d:\coverages", 0) Dim pWorkspace As IWorkspace Set pWorkspace = b_fc Dim pFeatClass As IFeatureClass Set pFeatClass = b_fc.OpenFeatureClass("box:annotation") 'Note: If the annotation has a subclass, the syntax becomes 'OpenFeatureClass("box:annotation.subclass") Dim pCovLayer As IFeatureLayer Set pCovLayer = New CoverageAnnotationLayer Set pCovLayer.FeatureClass = pFeatClass Dim pDataset As IDataset Set pDataset = b_fc pCovLayer.Name = pDataset.Name Dim pDoc As IMxDocument Set pDoc = ThisDocument pDoc.AddLayer pCovLayer
Get help from ArcGIS experts
Download the Esri Support App