English

How To: Activate an Edit Tool programmatically

Summary

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

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'
  3. Right-click the UIButtonControl and select View Source.
  4. Copy this code into the UIButtonControl's click event.
    Code:
    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
    

     
  5. Click AddData to load one editable layer.
  6. From the Tools Menu, click on the Editor toolbar.
  7. Click on the Editor pulldown and Start Editing.
  8. Click on the new button to run the code.
  9. Click on the map to use the tool. Notice that the selected edit tool is already depressed.