Add an item to a coverage feature class using VBA and ArcObjects

Last Published: April 25, 2020


This article shows how to add a new item to a coverage feature class in ArcMap.


  1. Start ArcMap.
  2. Open the Visual Basic Editor.

    In ArcMap, select Tools > Macros > Visual Basic Editor.

  3. In the Project Explorer window, expand Project.mxt and select ArcMap Objects > ThisDocument. Right-click and select View Code.
    [O-Image] Visual Basic Project  Explorer
    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.

  4. Copy the following into the code module.

    Public Sub additem()
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    Dim pFLayer As IFeatureLayer
    ' Get the first layer in ArcMap
    Dim pCovFClass As ICoverageFeatureClass
    Set pFLayer = pMxDoc.FocusMap.Layer(0)
    Set pCovFClass = pFLayer.FeatureClass
    Dim pArcItem As IArcInfoItem
    Dim pArcItemEdit As IArcInfoItemEdit
    Dim pFClass As IFeatureClass
    Set pFClass = pFLayer.FeatureClass
    Dim pArcTable As IArcInfoTable
    Set pArcTable = pCovFClass

    ' Check to see if an item called newitem exists
    ' and create the item if it doesn't
    If pFClass.FindField("newitem") = -1 Then
    Set pArcItem = New ArcInfoItem
    Set pArcItemEdit = pArcItem
    With pArcItemEdit
    .Name = "newitem"
    .Type = esriFieldTypeString
    .Width = 1
    .OutputWidth = 1
    End With
    pArcTable.additem pArcItem, "test"
    End If

  5. Close the Visual Basic Editor.
  6. Run the code.

    A. Click Tools > Macros > Macros to display the Macros dialog box.
    B. Select a macro and click Run.

Article ID:000004942

  • ArcMap 8 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options