Highlight Word formtext next to formcheckbox when selected
Hello everyone and thank you very much in advance.
I have formcheckbox next to formtext and I need the last ones to be highlighted when the first ones are checked.
I have obtained this code but it gives me an error in a protected area and the forms need protection.
How can I do it?
Sub CheckBox_Click()
Dim ff As FormField
Dim rng As Range
Set ff = Selection.FormFields(1) 'Assuming the check box is the only form field in the selection
Set rng = ff.Range 'The range of the check box
rng.MoveEnd wdWord, 1 'Extend the range to include the next word
If ff.CheckBox.Value = True Then 'If the check box is checked
rng.HighlightColorIndex = wdYellow 'Highlight the range with yellow color
Else 'If the check box is unchecked
rng.HighlightColorIndex = wdNoHighlight 'Remove the highlight from the range
End If
End Sub
|