microsoft excel macros

Page 186

Chapter 12  Adding Controls to Your Worksheets

Understanding the Two Sets of Controls I’m sure you couldn’t help but notice the strange shadow set of controls—nearly duplicates of the ActiveX set—shown in Figure 12-2. This second set is titled form controls and we’ve been avoiding dealing with them in this chapter. Why? Because they are less flexible and less useful than their ActiveX counterparts. They’re compatible with earlier versions of Excel, but are somewhat harder to work with, have few properties, can’t trigger events, and generally allow you less freedom. So, my suggestion is that you avoid them in favor of the ActiveX set of controls. However, there are a few situations where you might want to use a form control. ActiveX controls

require that you create an event handler (such as Button_Click), but the older form controls can directly trigger macros. This isn’t much of a difference really (you can just copy code from an existing macro and paste it into an event handler). But if you want to do something really simple and quick, like add a button that just executes an existing macro, go ahead and use a form control button if you wish. You can’t select form controls by clicking the Design Mode button. It has no effect on them. Instead, right-click it to select it. And you assign a macro to it by right-clicking, then choosing Assign Macro from the context menu. A list of your macros appears.

175

Figure 12-4  You can change many of the qualities of a control in its Properties window.


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.