English

How To: Run AML ARCEDIT, ARCPLOT or GRID commands from ArcCatalog or ArcMap

Summary

Create VBA code with the ESRI Arcedit or Arcplot ODE control and the 'ESRIutil automation server' reference. Then run the AML through the Command method of the Arcedit or Arcplot object.

Procedure

  1. Open the Visual Basic Editor.
  2. Add an ESRI ODE control as a Component.
    From the Insert menu click Components.
    Check the ESRI Arcedit, ESRI Arcplot, or ESRI Grid control.

    [O-Image] Adding an ESRI ODE control

  3. Add the ESRIutil automation server as a Reference.
    On the VBA editor Tools menu, click References. 
    Check "ESRIutil automation server".

    [O-Image] Adding ESRIutil automation server

  4. Create a new form.
    From the Insert menu, select UserForm.

    [O-Image] Adding a new form in VBA

  5. Add the ESRI control added in step two to the form.
    Right click on the ToolBox to open the Additional Controls dialog box.

    [O-Image] Add an additonal control to a form

  6. Add a new instance of the chosen ESRI control to the form menu interface.
  7. In the View menu > Properties Window, open the code for the desired document.

    Note:
    In ArcMap or ArcCatalog, this this may be Normal > Arcmap Objects > ThisDocument. ArcMap document code can also be added to Project > ArcMap Objects > ThisDocument.

  8. Add a subroutine to load the form and unload it once the AML has run.

    Code:
    'This subroutine is linked to a UIButtonControl
    'added to the ArcMap or ArcCatalog interface.
    Private Sub UIButtonControl2_Click()
    Load UserForm1
    Unload UserForm1
    End Sub

  9. In the Initialize event of the form's code, instantiate an ESRIutil.Strings object and use the ESRI control's Command method to run the AML.

    Code:
    'The Arcplot control is used in this example.
    Private Sub UserForm_Initialize()
    Dim Results As ESRIutil.Strings
    Dim ArcStatus As Long
    Set Results = New ESRIutil.Strings
    Results.Clear
    ArcStatus = Arcplot1.Command("&run c:\testdata\demo.aml", Results)
    Dim i As Integer
    Results.Clear
    End Sub

Related Information