Microsoft Office Tutorials and References
In Depth Information
Figure 10-1. Dialog for a charting utility
When the user clicks the button, a dialog box such as the one shown in Figure 10-1 a ppears,
allowing the user to make various selections and then create the chart or charts.
Figure 10-1. Dialog for a charting utility
In general, there are several possible options for providing access to the charting utility, that is, for
displaying the dialog box in Figure 10-1 ( or, for that matter, for providing access to any macro):
Select it from the Macro dialog by choosing Tools Macro Macros. The Macro
dialog was discussed in Chapter 4 . This is the most efficient method for a user who writes
macros and wants to run one quickly (and it provides an easy method to run many of the
very short examples presented in this topic). But since the dialog displays only the names
of macros to be run, it's not suitable for a user who is unfamiliar with the macros, nor is it
a very efficient method of running frequently used macros.
Run or display it automatically when a workbook opens by attaching code to one of
Excel's events, in this case the Open event. Events are discussed in detail in Chapter 11 .
Place a button directly on the worksheet.
Place a button on an existing Excel toolbar. This can be done programmatically (a topic
discussed in Chapter 12 ) or through the user interface (see Section 10.1.2 later in this
Create a new toolbar and add the button to it, either programmatically or through the user
interface. For information on the latter, see Section 10.1.1 l ater in this section.
Add a menu item to an existing Excel menu, either programmatically or through the user
Create a new menu bar and add a menu item, either programmatically or through the user
In this case, since we did not want the user to be able to invoke the chart-printing utility unless the
worksheet containing the pivot table was active, we opted for the button on the worksheet
approach. This is not to say, however, that the other approaches would not work.
On the other hand, if the utility in question has wider applicability, then it would probably make
more sense to use a toolbar or add a menu item. (I much prefer menu items over toolbar buttons,
because they are easily invoked using the keyboard and don't get in the way of other windows.)
Search JabSto ::

Custom Search