HOW TO

Activate an Edit Tool programmatically

Last Published: April 25, 2020

Summary

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.

This article illustrates how to activate one of the ArcMap edit tools programmatically.

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

Procedure

  1. Start ArcMap.
  2. Create a new UIButtonControl: How To: Create a new UIButtonControl​
Note:
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. Copy this code into the UIButtonControl's click event.
Dim pCmdBars As ICommandBars 
Dim pEditBar As ICommandBar
Dim pCmdItem As ICommandItem 
Dim pEditTool As ICommandItem 

Set pCmdBars = ThisDocument.CommandBars 

' Some of the Edit Tools. 

' This is the tool that you will use for this sample.  
Set pEditTool = pCmdBars.Find(ArcID.Editor_DistanceDistance) 

' Experiment with some of the remaining tools.  
' The Editor SketchTool is the default.
' ***** ArcID.Editor_SketchTool 

' Other tools
' ***** ArcID.Editor_IntersectionTool 
' ***** ArcID.Editor_Arc 

Set Application.CurrentTool = pEditTool
  1. Click AddData to load one editable layer.
  2. From the Tools menu, click on the Editor toolbar.
  3. Click the Editor pulldown and Start Editing.
  4. Click the new button to run the code.
  5. Click the map to use the tool. Notice that the selected edit tool is already depressed.

Article ID:000005797

Software:
  • 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