CheckBox Object (Word)

Represents a single check box form field.

Use FormFields(Index), where Index is index number or the bookmark name associated with the check box, to return a single FormField object. Use the CheckBox property with the FormField object to return a CheckBox object. The following example selects the check box form field named "Check1" in the active document.

ActiveDocument.FormFields("Check1").CheckBox.Value = True

The index number represents the position of the form field in the FormFields collection. The following example checks the type of the first form field; if it is a check box, the check box is selected.

If ActiveDocument.FormFields(1).Type = wdFieldFormCheckBox Then 
 ActiveDocument.FormFields(1).CheckBox.Value = True 
End If

The following example determines whether the ffield object is valid before changing the check box size to 14 points.

Set ffield = ActiveDocument.FormFields(1).CheckBox 
If ffield.Valid = True Then 
 ffield.AutoSize = False 
 ffield.Size = 14 
 MsgBox "First field is not a check box" 
End If

Use the Add method with the FormFields object to add a check box form field. The following example adds a check box at the beginning of the active document, sets the name to "Color", and then selects the check box.

With ActiveDocument.FormFields.Add(Range:=ActiveDocument.Range _ 
 (Start:=0,End:=0), Type:=wdFieldFormCheckBox) 
 .Name = "Color" 
 .CheckBox.Value = True 
End With
© 2015 Microsoft