Manipulating the Command Bars Collection

The CommandBars collection, contained in the Application object, is a collection of all CommandBar objects. Each CommandBar object has a collection of Controls. All these objects have properties and methods that enable you to control toolbars with VBA procedures.

In this section, I provide some key background information that you should know about before you start writing code to manipulate toolbars. As always, a thorough understanding of the object model will make your task much easier.

You manipulate Excel command bars (including toolbars) by using objects located within the CommandBars collection. This collection consists of the following items:

♦ All of Excel 2003's built-in toolbars (63 of them).

♦ Any other custom toolbars that you create.

♦ A built-in menu bar named Worksheet Menu Bar. This appears when a worksheet is active.

♦ A built-in menu bar named Chart Menu Bar. This appears when a chart sheet is active.

♦ Any other custom menu bars that you create.

♦ All of Excel 2003's built-in shortcut menus (61 of them).

+1 0

Post a comment