This document is archived and information here might be outdated.  Recommended version.


ICommandBar.CreateMacroItem Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Framework > ESRI.ArcGIS.Framework > Interfaces > IC > ICommandBar Interface > ICommandBar.CreateMacroItem Method
ArcGIS Developer Help

ICommandBar.CreateMacroItem Method

Creates a new macro item on this commandbar at the specified position.

[Visual Basic .NET]
Public Function CreateMacroItem ( _
    ByVal Name As String, _
    [ByRef FaceID As Object], _
    [ByVal Action As String], _
    [ByRef Index As Object] _
) As ICommandItem
[C#]
public ICommandItem CreateMacroItem (
    string Name,
    ref object FaceID,
    ref string Action,
    ref object Index
);

Product Availability

Available with ArcGIS Desktop.

Description

 

Name is a string representing the caption of the macro item. The caption is the string that appears when the macro item is placed on a menu.

FaceID specifies the image to be used for the button when the macro item is on a toolbar. Use either an index number of an icon in the built-in icon palette or the picture property of an Image control on a UserForm. [Optional]

Action is a string representing the full name of the VBA macro that is to be executed when the macro item is clicked. The name of the macro must include the name of the VBA project in which this macro is located. [Optional]

Index is a number representing the index location at which this macro item is to appear on the commandbar. [Optional]

 

Remarks

The values for FaceID using the built-in icon palette are:

Available Icons

Here are some examples of the syntax of the Action parameter.

Macro called MyMacro in ThisDocument in Normal template:
"Normal.ThisDocument.MyMacro"

Macro called MyMacro in Module1 in Normal template:
"Normal.Module1.MyMacro"

Macro called MyMacro in ThisDocument in the current document:
"Project.ThisDocument.MyMacro"

Macro called MyMacro in Module1 in the current document:
"Project.Module1.MyMacro"

Macro called MyMacro in ThisDocument in a base template:
"TemplateProject.ThisDocument.MyMacro"

Macro called MyMacro in Module1 in a base template:
"TemplateProject.Module1.MyMacro"

 

Note: Macros must be Public Subs. Private Subs are not treated as macros.

See Also

ICommandBar Interface | ICommandItem Interface