Microsoft Office Tutorials and References
In Depth Information
Figure 14-4. Response to placing a standard Excel command button
The controls on the Control Toolbox (on the left in Figure 14-3 ) are ActiveX controls. These
controls can be placed either on a UserForm or directly on a worksheet (but not a chartsheet).
They are the same as the controls that are accessible from the VB editor's Toolbox when designing
a UserForm. ActiveX controls are very flexible and generally support a wide range of events. The
Control Toolbox can be opened from within Excel (not the Excel VBA IDE) by selecting the
Customize option from the Tools menu and checking the Control Toolbox toolbar in the Toolbars
tab.
Note that the Control Toolbox in Figure 14-3 i s not the same as the Toolbox in Figure 14-1 , even
though both are used to access ActiveX controls. The Toolbox in Figure 14-1 p laces ActiveX
controls on user forms; the Control Toolbox in Figure 14-3 places ActiveX controls on worksheets.
The first button on the Control Toolbox, called the Design Mode button, is particularly important.
Pressing it puts the worksheet in design mode at least with respect to its controls. When in design
mode, we can move and resize the controls on the worksheet using the mouse. We can also
rightclick the control to bring up a dialog box with control options. When the Design Mode button is
not depressed, clicking on a control with the mouse simply fires the Click event!
By selecting the Customize option from the Tools menu and checking the Forms toolbar in the
Toolbars tab, you open the Forms toolbox. The controls on the Forms toolbox (on the right in
Figure 14-3 ) are referred to as "standard Excel worksheet controls" and are a remnant from Excel
5.0. They can be placed on worksheets or chartsheets (but not UserForms) and have only a single
event: the Click event.
For instance, if you place a standard button on a worksheet, Excel immediately opens the Assign
Macro dialog box, as shown in Figure 14-4 . This allows you to assign a macro to the button's
Click event.
Figure 14-4. Response to placing a standard Excel command button
Since standard Excel controls are the only controls that can be placed on a chartsheet, they remain
useful. But ActiveX controls are far more flexible and should be used whenever possible. We will
speak no further about the standard Excel controls.
14.6 Example: The ActivateSheet Utility
It is time now to implement the ActivateSheet utility in our SRXUtils application. This will
demonstrate the use of UserForms.
 
 
 
Search JabSto ::




Custom Search