Create Toolbars in Code

Because custom toolbars are easier to distribute than custom menus, there is less reason to create them in code; however, you can if you like. Toolbars are CommandBar objects, just like menus, but they have a Type property set to msoBarTypeNormal. You get a reference to a toolbar from the Application object’s CommandBars collection using the toolbar’s name. The toolbars are:

3-D Settings

Align or Distribute

Annotation Pens

AutoShapes

Basic Shapes

Block Arrows

Borders

Callouts

Chart

Chart Type

Circular Reference

Clipboard

Compare Side by Side

Connectors

Control Toolbox

Diagram

Draw Border

Drawing

Drawing and Writing Pens

Drawing Canvas

Envelope

Exit Design Mode

External Data

Fill Color

Flowchart

Font Color

Formatting

Forms

Formula Auditing

Full Screen

Ink Annotations

Ink Drawing and Writing

Insert Shape

Line Color

Lines

List

Nudge

Online Meeting

Order

Organization Chart

Pattern

Picture

PivotTable

PivotTable Field List

Protection

Refresh

Reviewing

Rotate or Flip

Shadow Settings

Standard

Stars & Banners

Stop Recording

Task Pane

Text To Speech

Visual Basic

Watch Window

Web

WordArt

  

Use the CommandBar object’s Show method to display a toolbar. For example, the following code displays each of the toolbars in turn, pausing between each. This is useful for finding the name of a particular toolbar:

Sub ShowToolbars( ) Dim cb As CommandBar, show As Boolean For Each cb In Application.CommandBars If cb.Type ...

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.