Forms Controls

A good reason for using the Forms controls is that they are simpler to use than the ActiveX controls, because they do not have all the features of ActiveX controls. For example, Forms controls can only respond to a single, predefined event, which is usually the mouse-click event. ActiveX controls can respond to many events, such as a mouse click, a double-click, or pressing a key on the keyboard. If you have no need of such features, you might prefer the simplicity of Forms controls. To create a Forms button in a worksheet, click the top-left button in the Controls dialog box, opened from the Insert button on the Developer tab of the Ribbon.

You can now draw the button in your worksheet by clicking where you want a corner of the button to appear and dragging to where you want the diagonally opposite corner to appear. The Assign Macro dialog box will appear as shown in Figure 1-9, and you can select the macro to attach to the button.

Figure 1-9

Click OK to complete the assignment. You can then edit the text on the button to give a more meaningful indication of its function. After you click a worksheet cell, you can click the button to run the attached macro. If you need to edit the button and it is not already selected, right-click it to select the control and display a context menu. If you don't want the context menu, hold down Ctrl and left-click or right-click the button to select it. (Don't drag the mouse while you hold down Ctrl, or you will create a copy of the button.)

If you want to align the button with the worksheet gridlines, hold down Alt as you draw it with the mouse. If you have already drawn the button, select it and hold down Alt as you drag any of the white boxes that appear on the corners and edges of the button. The edge or corner you drag will snap to the nearest gridline.

0 0

Post a comment