AddCommandBarButton Method

Home Page (Objects)OverviewFAQReference

Applies to: Application object

Creates a toolbar and toolbar buttons for an add-in.

Syntax

object**.AddCommandBarButtonbutton_type,command_name,**cookie

Parameters

object

An expression that evaluates to an Application object. When you use the AddCommandBarButton method of the Application object, you can omit object because the name of the Application object is implied when you access its properties and methods.

button_type

A Long representing the button type. Possible values are:

  • dsGlyph   Requires that the button display only an image. (The button looks like a standard toolbar button.)

  • dsText   Requires that the button display only button text. (The button looks like a menu such as "File" or "Edit.")

command_name

A String containing the name of the command the button will carry out. This name must match the name added by the AddCommand method.

cookie

A Long representing the identifier of the add-in. Developer Studio passed this value to the add-in through the add-in's OnConnection method.

Remarks

Only add-ins can call the AddCommandBarButton method. VBSscript macros cannot.

Example

The following example, which is written in Visual C++, is the code automatically generated when you create an add-in using the Developer Studio Add-in Wizard:

if (bFirstTime == VARIANT_TRUE)
{
   VERIFY(SUCCEEDED(pApplication->
      AddCommandBarButton(dsGlyph, bszCmdName, m_dwCookie)));
}

See Also   AddCommand method, Adding Commands to Developer Studio, AddKeyBinding method, EnableModeless method, SetAddInInfo method.