ToolbarButton Object

Description

Represents a button or a gap (an extended space between buttons) on a toolbar. Do not confuse the ToolbarButton object with the Button object, which is a custom button graphic object on a chart sheet, dialog sheet, or worksheet.

Accessors

The ToolbarButton object is a member of the ToolbarButtons collection. The ToolbarButtons collection contains all the ToolbarButton objects on a single toolbar. Use the Add method to create a new toolbar button and add it to the collection. For a complete list of available toolbar buttons, see "Toolbar Button ID Values" in online Help.

To access a single member of the collection, use the ToolbarButtons method with the toolbar button index number as an argument.

The index number represents the position of the toolbar button on the toolbar. ToolbarButtons(1) is the first (leftmost) button on the toolbar; ToolbarButtons(ToolbarButtons.Count) is the last. The following example deletes the last button on the Standard toolbar.


With Toolbars("standard")
    .ToolbarButtons(.ToolbarButtons.Count).Delete
End With

The following example creates a table on worksheet one in the active workbook. The table contains the names of all the ToolbarButton objects in all the Toolbar objects in the application. The column headings are the Toolbar object names, and the column entries under each heading are the names of the ToolbarButton objects in that Toolbar object. ToolbarButton objects that represent gaps (extended spaces between buttons) have no name; their corresponding cells are therefore blank.


Sub EnumerateToolbars()
    Worksheets(1).Activate
    For col = 1 To Toolbars.Count
        Cells(1, col) = Toolbars(col).Name
        For rw = 2 To Toolbars(col).ToolbarButtons.Count + 1
            Cells(rw, col) = Toolbars(col).ToolbarButtons(rw - 1).Name
        Next
    Next
End Sub

Remarks

The Name property sets or returns the toolbar button tool tip text (the text displayed when the user moves the mouse cursor over the toolbar button).

Properties

Application Property, BuiltIn Property, BuiltInFace Property, Creator Property, Enabled Property, HelpContextID Property, HelpFile Property, Id Property, IsGap Property, Name Property, OnAction Property, Parent Property, Pushed Property, StatusBar Property, Width Property.

Methods

Copy Method, CopyFace Method, Delete Method, Edit Method, Move Method, PasteFace Method, Reset Method.