Note: This article pertains to ArcGIS versions 8.x and 9.x. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.
Instructions provided describe how to export a selected set of features from a joined feature class and table to a new shapefile using VBA and 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'
Dim pMxDoc As IMxDocument Dim pFLayer As IFeatureLayer Dim pDataset As IDataset Dim pDSName As IDatasetName Dim pDispTable As IDisplayTable Dim pShapeFCName As IDatasetName Dim pShapeWSF As IWorkspaceFactory Dim pShapeWS As IDataset Dim pShapeWSName As IWorkspaceName Dim pQFilter As IQueryFilter Dim pExportOp As IExportOperation Set pMxDoc = Application.Document Set pFLayer = pMxDoc.FocusMap.Layer(0) Set pDispTable = pFLayer Set pDataset = pDispTable.DisplayTable Set pDSName = pDataset.FullName Set pShapeWSF = New ShapefileWorkspaceFactory Set pShapeWS = pShapeWSF.OpenFromFile("C:\temp", 0) Set pShapeWSName = pShapeWS.FullName Set pShapeFCName = New FeatureClassName pShapeFCName.Name = "Export_test" Set pShapeFCName.WorkspaceName = pShapeWSName ' Set up query sub fields: a comma-delimited list of the fields you want ' Or "*" for all fields in the joined feature class Dim strFld As String strFld = "*" Set pQFilter = New QueryFilter pQFilter.SubFields = strFld Set pExportOp = New ExportOperation pExportOp.ExportFeatureClass pDSName, pQFilter, Nothing, Nothing, pShapeFCName, 0