AnsweredAssumed Answered

How can I set my custom tool active in ArcMap?

Question asked by sergey.gamayunov_1 on Sep 17, 2014
Latest reply on Sep 17, 2014 by sergey.gamayunov_1

I've tried this snippet:

///<summary>Find a specific tool (or command) in a toolbar and set it to be active.</summary>


///<param name="application">An IApplication interface.</param>

///<param name="toolName">A System.String that is the name of the command to return. Example: "esriFramework.HelpContentsCommand"</param>


///<remarks>Refer to the EDN document for a listing of available CLSID's and ProgID's that can be used as the toolName parameter.</remarks>

public void SetToolActiveInToolBar(ESRI.ArcGIS.Framework.IApplication application, System.String toolName)


  ESRI.ArcGIS.Framework.ICommandBars commandBars = application.Document.CommandBars;

  ESRI.ArcGIS.esriSystem.UID commandID = new ESRI.ArcGIS.esriSystem.UIDClass();

  commandID.Value = toolName; // example: "esriArcMapUI.ZoomInTool";

  ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(commandID, false, false);


  if (commandItem != null)

  application.CurrentTool = commandItem;


Buuuut, I have no idea, how run it. What should I get to ESRI.ArcGIS.Framework.IApplication application?