Use ArcObjects to convert VPF data to a geodatabase

Last Published: April 25, 2020


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.

The following sample code will convert a VPF dataset to a personal geodatabase dataset.

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


  1. Open ArcMap.
  2. Create a new UIButtonControl: How To: Create a new UIButtonControl
 For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
  1. Right-click the UIButtonControl and select View Source.
  2. Paste this code into the UIButtonControl's click event. Please note that changes will need to be made to path and file names in this code.
Sub vpf2gdb()
' This runs from ArcMap.

'Set the InputWorkspaceFactory.
Dim pInWorkspaceFact As IWorkspaceFactory
Set pInWorkspaceFact = New VpfWorkspaceFactory

'Create a PropertySet with which to open workspace.
Dim pInPropSet As IPropertySet
Set pInPropSet = New PropertySet
pInPropSet.SetProperty "database", "E:\WORK\UVMAP\UVMAP"

'Open Workspace.
Dim pInWorkspace As IWorkspace
Set pInWorkspace = pInWorkspaceFact.Open(pInPropSet, 0)

Dim pFeatWorkspace As IFeatureWorkspace
Set pFeatWorkspace = pInWorkspace

'Open the Feature Dataset.
Dim pFeatDataset As IFeatureDataset
Set pFeatDataset = pFeatWorkspace.OpenFeatureDataset("baydhabo:trans")

'Set Dataset Name.
Dim pInDatasetName As IDatasetName
Set pInDatasetName = pFeatDataset.FullName

'Set up the Output WorkspaceFactory.
Dim pOutWorkspaceFactory As IWorkspaceFactory
Set pOutWorkspaceFactory = New AccessWorkspaceFactory

'Create a PropertySet with which to open workspace.
Dim pOutPropSet As IPropertySet
Set pOutPropSet = New PropertySet
pOutPropSet.SetProperty "Database", "e:\work"

'Create output WorkspaceName.
Dim pOutWorkspaceName As IWorkspaceName
Set pOutWorkspaceName = pOutWorkspaceFactory.Create("e:\work", _
        "VPFtoGDB", pOutPropSet, 0)

Dim pOutFeatDatasetName As IFeatureDatasetName
Set pOutFeatDatasetName = New FeatureDatasetName

Dim pOutDatasetName As IDatasetName
Set pOutDatasetName = pOutFeatDatasetName
Set pOutDatasetName.WorkspaceName = pOutWorkspaceName
pOutDatasetName.Name = pInDatasetName.Name

'QI for IFeatureDatasetName
Dim pFeatDatasetName As IFeatureDatasetName
Set pFeatDatasetName = pInDatasetName

Dim pEnumDS_FCName As IEnumDatasetName
Set pEnumDS_FCName = pFeatDatasetName.FeatureClassNames
Dim pDS_FCName As IDatasetName
Set pDS_FCName = pEnumDS_FCName.Next

  'Convert each featureclass in enumeration.
  Do While Not pDS_FCName Is Nothing

    'QI for IFeatureClassName
    Dim pFeatClassName As IFeatureClassName
    Set pFeatClassName = pDS_FCName

    'QI for IName
    Dim pName As IName
    Set pName = pFeatClassName

    'Open FeatureClass
    Dim pFeatClass As IFeatureClass
    Set pFeatClass = pName.Open

    'QI for IDataset
    Dim pTempDataset As IDataset
    Set pTempDataset = pFeatClass

    'Use IFieldChecker to verify the field names are valid.
    Dim pFields As IFields
    Dim pValidatedFields As IFields
    Dim pFieldChecker As IFieldChecker

    'Get Fields from FeatureClass.
    Set pFields = pFeatClass.Fields
    Set pFieldChecker = New FieldChecker
    pFieldChecker.Validate pFields, Nothing, pValidatedFields

    'Create the new output. FeatureClassName object
    Dim pOutFeatClassName As IFeatureClassName
    Set pOutFeatClassName = New FeatureClassName

    'QI for IDatasetName
    Dim pOutDataset_FCName As IDatasetName
    Set pOutDataset_FCName = pOutFeatClassName

    'Set the Name of the FeatClassName.
    pOutDataset_FCName.Name = pTempDataset.Name

    Dim pFeatDataConv As IFeatureDataConverter
    Set pFeatDataConv = New FeatureDataConverter
    pFeatDataConv.ConvertFeatureClass pFeatClassName, Nothing, _
        pOutFeatDatasetName, pOutFeatClassName, Nothing, _
        pValidatedFields, "", 1000, 0

    Set pDS_FCName = pEnumDS_FCName.Next


End Sub

Article ID:000004896

  • ArcMap 8 x
  • ArcMap 9 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic