Microsoft Knowledge Base
XL5: Changing State of Control Is Not Recorded
Last reviewed: March 27, 1997
Article ID: Q110501
5.00 7.00 | 5.00
WINDOWS MACINTOSH
kbusage
The information in this article applies to:
- Microsoft Excel for Windows, version 5.0
- Microsoft Excel for the Macintosh, version 5.0
- Microsoft Excel for Windows 95, version 7.0
SYMPTOMS
In Microsoft Excel, if you run the Macro Recorder and change the state of a control either on a worksheet or in a custom dialog box by selecting the control, this change is not recorded in your macro.
CAUSE
This behavior is by design because you do not always want to record the change of the state of a control when you are recording a macro. For example, you may want to record an event macro that will perform an action regardless of the value of the control.
WORKAROUND
To change the state of a control on a worksheet or in a custom dialog box, use either of the procedures below.
Set Initial State of Control
To set the initial state of a button or check box control, do the following:
- Select the control and choose Object from the Format menu.
- Select the Control tab, and under Value, select the value you want the control to have.
Change State of Control Within a Macro
To change the state of a control within a macro, use a command to change the Value property of the control. The available values for each control vary with the control. For information about the Value properties of each control, choose the Search button in the Visual Basic Reference and type the following:
Value Property
MORE INFORMATION
If you have assigned a procedure to the selection of a control, the procedure is recorded when you select that control while the macro recorder is running.
For example, if you assign the procedure Check_Box_Selected to a check box on your worksheet, the following code is written when you run the Macro Recorder and select the check box
Application.Run Macro:="Book1!Check_Box_Selected"
(where BOOK1 is the name of the workbook containing the procedure that Check_Box_Selected). Use the Assign Macro command on the Tools menu to assign a macro to the selected control.
REFERENCES
"Visual Basic User's Guide," pages 219-239
For more Tips For Working With Graphic Objects or Information On Controls, choose the Search button in Help and type:
controls
KBCategory: kbusage Last reviewed: March 27, 1997 |