Excel 2007 Power Programming with VBA (Mr. Spreadsheets Bookshelf)

The first thing you notice about Excel 2007 is its new look. The time-honored menu-and-toolbar user interface has been scrapped and replaced with a new tab-and-Ribbon interface. Although the new interface kind of resembles the old-fashioned menus -and- toolbars interface, you'll find that it's radically different.

Long-time Excel users have probably noticed that the menu system has become increasingly complicated with each new version. In addition, the number of toolbars has become almost overwhelming. After all, every new feature must be accessible. In the past, this access meant adding more items to the menus and building new toolbars. The Microsoft designers set out to solve this overcrowding problem, and the new Ribbon interface is their solution.

Time will tell how users will accept the new Ribbon interface. As I write this book, the reaction can best be described as mixed. As with anything new, some people love it, and others hate it.

I think many experienced Excel users will suffer from a mild case of bewilderment when they realize that all their familiar command sequences no longer work. Beginning users, on the other hand, will be able to get up to speed much more quickly because they won't be overwhelmed with irrelevant menus and toolbars.

Because the Ribbon UI is new, I provide some additional user-oriented information in the sections that follow.

Ribbon tabs

The commands available in the Ribbon vary, depending on which tab is selected. The Ribbon is arranged into groups of related commands. Here's a quick overview of Excel's tabs:

The CommandBar Object in Excel 2007

Excel 97 introduced a completely new way of handling toolbars and menus. These UI elements are CommandBar objects. What's commonly called a toolbar is actually one of three types of command bars:

For compatibility purposes, Excel 2007 still supports the CommandBar object - but its functionality has been significantly deprecated. It's no longer possible for an end user to create a custom toolbar. However, a VBA programmer can still create and work with CommandBar objects (see "Creating an Old-Style Toolbar," later in this chapter). The problem, however, is that many of the CommandBar properties and methods are simply ignored in Excel 2007. For example, every toolbar or customized menu appears in the Add-Ins tab of the Ribbon. Properties that control a toolbar's dimensions and position no longer work. In addition, floating toolbars are no longer possible.

The accompanying figures show a customized menu and toolbar in Excel 2003, and the same menu and toolbar in Excel 2007. Although these UI elements are still functional in Excel 2007, it's clearly not what the developer (me!) had in mind. Needless to say, many VBA developers will want to redo the UI for their applications.

In this chapter, I present a simple example of creating a custom toolbar by using the CommandBar object (see "Creating an Old-Style Toolbar"). For complete details on creating custom menus and toolbars with the CommandBar object, consult the previous edition of this book.

Customizing shortcut menus is still supported in Excel 2007, and I cover that topic in Chapter 23.

 

The appearance of the commands on the Ribbon varies, depending on the width of the Excel window. When the window is too narrow to display everything, the commands adapt and may seem to be missing, but the commands are still available. Figure 22-1 shows three views of the Home tab of the Ribbon. In the top image, all controls are fully visible. In the middle image, Excel's window is made narrower. Notice that some of the descriptive text is gone, and some of the icons are smaller. The bottom image shows the extreme case in which the window is very narrow. Some groups display a single icon. However, if you click the icon, all the group commands are available to you.

Figure 22-1: The Home tab of the Ribbon, with varying widths of the Excel window.

Tip  

If you would like to hide the Ribbon to increase your worksheet view, just double-click any of the tabs. The Ribbon goes away (but the tabs remain ), and you're able to see about five additional rows of your worksheet. When you need to use the Ribbon again, just click a tab, and it comes back temporarily. To permanently restore the Ribbon, double-click a tab. You can also press Ctrl+F1 to toggle the Ribbon display on and off.

Категории