Command Bars

The CommandBars collection is an object contained in the Office Object Model, documented in Appendix C. It contains all the menus, toolbars, and shortcut popup menus that are already built into Excel and the other Office applications, as well as any of those objects that you create yourself. You access command bars through the CommandBars property of the Application object.

Command bars were first introduced into Office in Office 97. Excel 5 and 95 supported menu bars and toolbars as separate object types. Shortcut menus, or popups, such as those that appear when you right-click a worksheet cell, were a special type of menu bar. In Excel 97 and later versions, command bar is a generic term that includes menu bars, toolbars, and shortcut menus.

Excel 2007 has made a giant leap forward and replaced menus and toolbars with the Ribbon to provide access to commands. Only the popup type command bars are included in the standard Excel 2007 user interface. However, Excel 2007 still maintains all the old command bars internally and still allows you to create your own command bars, although the way menus and toolbars are exposed is different compared with previous versions. User-defined menus and toolbars now appear in the Add-Ins tab of the Ribbon.

The Visual Basic Editor window in Excel 2007 still has the menu and toolbar interface it has always supported. You can manipulate the VBE command bars using the same techniques that are outlined in this chapter. See Chapter 26 for more information.

Command bars contain items that are called controls. When clicked, some controls execute operations, such as copy. Until this chapter gets down to the nuts and bolts, these types of controls will be referred to as commands. There are other controls, such as File, that produce an additional list of controls when clicked. These controls are referred to as menus. You can create new controls, or you can use the built-in controls that come with Excel.

This chapter shows you how to create and manipulate these useful tools. It takes a look at how command bars were used in Excel 2003 and then shows how to use them in Excel 2007.

0 0

Post a comment