Toolbar Object

Description

Represents a toolbar, either built-in or custom.

Accessors

The Toolbar object is a member of the Toolbars collection. Use the Add method to create a new toolbar and add it to the collection. To access a single member of the collection, use the Toolbars method with the index number or name of the toolbar as an argument.

The toolbar index number represents the position of the toolbar name in the list shown in the Toolbars dialog box (Toolbars command, View menu). Toolbars(1) is at the top of the list; Toolbars(Toolbars.Count) is at the bottom. Built-in toolbars are shown first, with custom toolbars arranged alphabetically after the last built-in toolbar.

The following example moves the Standard toolbar to the bottom of the Microsoft Excel window.


Toolbars(1).Position = xlBottom

The Name property returns the toolbar name (as shown in the Toolbars dialog box). The Name property is read-only; you cannot change the name of a built-in or custom toolbar. The following example makes the Forms toolbar visible.


Toolbars("forms").Visible = True

The following example creates a table on worksheet one in the active workbook that 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

Properties

Application Property, BuiltIn Property, Creator Property, Height Property, Left Property, Name Property, Parent Property, Position Property, Protection Property, Top Property, Visible Property, Width Property.

Methods

Delete Method, Reset Method, ToolbarButtons Method.