10

Adding Controls

As we have already discussed in Chapter 1, you can add two different types of controls to Excel worksheets. You can use ActiveX controls, found on the Control Toolbox toolbar, or the controls from the Forms toolbar. The Forms toolbar is an Excel 5 and Excel 95 feature, and provided controls for the dialog sheets used in those versions, as well as controls that can be embedded in a worksheet or chart. Dialog sheets have been superseded by UserForms since the release of Excel 97, and UserForms utilize the ActiveX controls.

The Toolbars

The Forms toolbar controls, shown in Figure 10-1, and dialog sheets are still supported in Excel, however. The Forms toolbar controls even have some advantages over the ActiveX controls.

images

Figure 10-1

The Forms controls are less complex than the ActiveX controls and, if you want to place controls on a chart sheet, you can only use the Forms toolbar controls. However, each Forms toolbar control can only respond to a single event. In most cases, that event is the Click event—the edit box is an exception, responding to the Change event.

If you want to create controls and define their event procedures in your VBA code, as opposed to creating them manually, the Forms toolbar controls are easier to work with. A big advantage over an ActiveX control is that the event procedure for a Forms toolbar control can be placed in a standard module, ...

Get Excel 2003 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.