Article ID: 182427
Article Last Modified on 7/13/2007
Sub ToggleCheckBoxOnEntry()
Dim fFields As FormFields
Dim fSelectedField As FormField
Set fFields = ActiveDocument.FormFields
For Each fSelectedField In Selection.FormFields
' Form field must be a check box.
If fSelectedField.Type = wdFieldFormCheckBox Then
' Go to the case for the currently selected group.
Select Case fSelectedField.Name
' Yes, No, or Undecided check box group.
Case "Yes", "No", "Undecided"
' Clear all values.
fFields("Yes").CheckBox.Value = False
fFields("No").CheckBox.Value = False
fFields("Undecided").CheckBox.Value = False
' True or False check box group.
Case "True", "False"
' Clear all values.
fFields("True").CheckBox.Value = False
fFields("False").CheckBox.Value = False
' You can add other Case statements for other groupings.
' For example:
'Case
' <Code>
'Case
' <Code>
Case Else
End Select
' Check the selected formfield.
fSelectedField.CheckBox.Value = True
End If
Next
End Sub
To use this macro for any check box grouping within your document, assign
ToggleCheckBoxOnEntry() as the Entry macro for every Check Box Form Field
in the group.
176476 OFF: Office Assistant Not Answering Visual Basic Questions
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon vb vba vbe
Keywords: kbcode kbdtacode kbhowto kbmacroexample kbprogramming KB182427