M

Ci tfi SIKMF*4

UfKterinî:

HíflUtr

Itafc

50<J

Color:

11

i

A

f

1Ü1

_.

11

1Î [w

AaBbCCYyZl

~|p& "j j TrueType foni. Hie same fan a on L"j"Ji prrfr aid íülf kw

Canot)

Figure 12-12: Using the ExecuteMso method to display a dialog box.

Application.CommandBars.ExecuteMso("FormatCellsFontDialog")

Executing an Old Menu Item Directly

Another technique to display a built-in dialog box requires knowledge of the pre-Excel 2007 toolbars (officially known as CommandBar objects). Although Excel 2007 no longer uses CommandBar objects, they are still supported for compatibility.

The following statement, for example, is equivalent to selecting the Go To menu item on the Edit menu:

Application.CommandBars("Worksheet Menu Bar"). _ Controls("Edit").Controls("Go To...").Execute

This statement, when executed, displays the Go To dialog box. Notice that the menu item captions must match exactly (including the ellipsis after Go To).

Here's another example. This statement displays the Format Cells dialog box:

Application.CommandBars("Worksheet Menu Bar"). _

Controls("Format").Controls("Cells...").Execute

It's probably not a good idea to rely on CommandBar objects because they may be removed from a future version of Excel.

4 PREV

NEXT

0 0

Post a comment