Toolbars Collection Object

Description

A collection of all the Toolbar objects in the Microsoft Excel application. Each Toolbar object represents a toolbar, either built-in or custom.

Accessors

Use the Add method to create a new toolbar and add it to the collection. The following example creates a new toolbar called "small VBA," adds the Insert Module button (190) and the Run Macro button (100) to it, makes the new toolbar visible, and moves it to the top of the Microsoft Excel window.


Dim tb As Toolbar
Set tb = Toolbars.Add("small VBA")
tb.ToolbarButtons.Add 190    'Insert Module button
tb.ToolbarButtons.Add 100    'Run Macro button
tb.Visible = True
tb.Position = xlTop

Use the Toolbars method with an argument to access a single member of the collection or without an argument to access the entire collection at once. The following example displays the total number of toolbars currently available in Microsoft Excel and the number of built-in toolbars.


cToolbars = Toolbars.Count
cBuiltIn = 0
For i = 1 To cToolbars
    If Toolbars(i).BuiltIn Then cBuiltin = cBuiltin + 1
Next
MsgBox cToolbars & " toolbars, " & cBuiltin & " built in."

Properties

Application Property, Count Property, Creator Property, Parent Property.

Methods

Add Method (Toolbars Collection), Item Method.