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
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 ...