O'Reilly logo

Excel 2003 VBA Programmer's Reference by Robert Rosenberg, Rob Bovey, John Green, Stephen Bullen, Paul T. Kimmel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

26

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 commandbars through the CommandBars property of the Application object.

Commandbars 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 which appear when you right-click a worksheet cell, were a special type of menu bar. In Excel 97 and later versions, the “command bar” is a generic term that includes menu bars, toolbars, and shortcut menus.

Commandbars contain items that are called controls. When clicked, some controls execute operations, such as Copy. Until we get down to the nuts and bolts, we will refer to these types of controls as commands. There are other controls, such as File, that produce an additional list of controls when clicked. We will refer to these controls as menus.

In this chapter, we will show you how to create and manipulate these useful tools.

Toolbars, Menu Bars, and Popups

The screenshot in Figure 26-1 shows the standard Worksheet menu bar at the top of the Excel window.

The Worksheet menu bar contains menus, such as File and Edit. When you click a menu, you see another list containing commands and menus.

  • Cut and Copy are examples ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required