Obtain a command by specifying it's name.
[C#]
///<summary>Obtain a command by specifying it's name.</summary> /// ///<param name="application">An IApplication interface.</param> ///<param name="commandName">A System.String that is the name of the command to return. Example: "esriFramework.HelpContentsCommand"</param> /// ///<returns>An ICommandItem interface.</returns> /// ///<remarks>Refer to the EDN document http://edndoc.esri.com/arcobjects/9.1/default.asp?URL=/arcobjects/9.1/ArcGISDevHelp/TechnicalDocuments/Guids/ArcMapIds.htm for a listing of available CLSID's and ProgID's that can be used as the commandName parameter.</remarks> public ESRI.ArcGIS.Framework.ICommandItem GetCommand(ESRI.ArcGIS.Framework.IApplication application, System.String commandName) { ESRI.ArcGIS.Framework.ICommandBars commandBars = application.Document.CommandBars; ESRI.ArcGIS.esriSystem.UID commandID = new ESRI.ArcGIS.esriSystem.UIDClass(); commandID.Value = commandName; // Example: "esriFramework.HelpContentsCommand" return commandBars.Find(commandID, false, false); }
[Visual Basic .NET]
'''<summary>Obtain a command by specifying it's name.</summary> ''' '''<param name="application">An IApplication interface.</param> '''<param name="commandName">A System.String that is the name of the command to return. Example: "esriFramework.HelpContentsCommand"</param> ''' '''<returns>An ICommandItem interface.</returns> ''' '''<remarks>Refer to the EDN document http://edndoc.esri.com/arcobjects/9.1/default.asp?URL=/arcobjects/9.1/ArcGISDevHelp/TechnicalDocuments/Guids/ArcMapIds.htm for a listing of available CLSID's and ProgID's that can be used as the commandName parameter.</remarks> Public Function GetCommand(ByVal application As ESRI.ArcGIS.Framework.IApplication, ByVal commandName As System.String) As ESRI.ArcGIS.Framework.ICommandItem Dim commandBars As ESRI.ArcGIS.Framework.ICommandBars = application.Document.CommandBars Dim commandID As ESRI.ArcGIS.esriSystem.UID = New ESRI.ArcGIS.esriSystem.UIDClass commandID.Value = commandName ' Example: "esriFramework.HelpContentsCommand" Return commandBars.Find(commandID, False, False) End Function