Microsoft KB Archive/87111

{|
 * width="100%"|

Setting and Evaluating Values for a Dialog CheckBox

 * }

Q87111

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c, 2.0c
 * Microsoft Word for Windows, versions 7.0, 7.0a
 * Microsoft Word for the Macintosh, versions 6.0, 6.0.1

-

SUMMARY
User-defined dialog boxes created in the Microsoft Word for Windows macro language, can include check boxes that are marked, unmarked, or unavailable (dimmed). To set the default value for a check box, set the CheckBox dialog argument to one of the following values:

 0   Clear the check box 1  Place an X in the check box -1  Make the check box unavailable (dimmed) These values are also returned to indicate the status of the check box. For example, if the user marks a check box, the value &quot;1&quot; is returned to indicate that the box was selected (marked).

To check the return value for a CheckBox statement, add a command similar to the following just below the Dialog statement:

  x = Dlg.CheckBox1

Dlg = the dialog box array CheckBox1 = dialog box field name If the &quot;x&quot; variable evaluates to be &quot;1&quot;, CheckBox1 in the UserDialog was selected.

The following macro evaluates CheckBox1 in the UserDialog dialog record:

 Sub MAIN Begin Dialog UserDialog 320, 120 OKButton 210, 56, 88, 22 CancelButton 211, 83, 88, 21 CheckBox 35, 24, 196, 17, &quot;Check Box&quot;, .CheckBox1 End Dialog Dim dlg As UserDialog n = Dialog(dlg) x = dlg.checkbox1                 'assign status of Checkbox1 to x   If x = 1 Then MsgBox &quot;Checkbox was checked&quot; End Sub

MORE INFORMATION
In addition to evaluating check boxes, CheckBox statements can be set to default values. The following macro fills CheckBox1 with gray in the UserDialog dialog record:

 Sub MAIN Begin Dialog UserDialog 320, 120 OKButton 210, 56, 88, 22 CancelButton 211, 83, 88, 21 CheckBox 35, 24, 196, 17, &quot;Greyed Check Box&quot;, .CheckBox1 CheckBox 35, 42, 111, 16, &quot;Check Box&quot;, .CheckBox2 End Dialog Dim dlg As UserDialog dlg.CheckBox1 = - 1               'Sets CheckBox1 to gray n = Dialog(dlg) End Sub The default display for a CheckBox statement is clear (no check mark).

Word 6.0 for Windows
In order to actually disable an item in a dialog, use the DlgEnable statement within a dialog function. DlgEnable allows you to enable or disable the dialog box control identified by Identifier[$] while the dialog box is displayed. When a dialog box control is disabled, it is visible in the dialog box, but is dimmed and not functional.

For information about using a dialog function, see the &quot;Creating Dynamic Dialog Boxes&quot; topic in the Online Help file for Word 6.0 for Windows.