Hi Rob,
This depends on how your table looks. Assuming that checkbox, formfield and
text are all in one cell, you can use code like this that formats the entire
cell's font black or white. Select the ToggleHideCell procedure as the on
exit macro of the checkbox.
---------------------------------------------------------------------------------------------------------------------
Sub ToggleHideCell()
Dim oCell As Cell
Set oCell = Selection.Cells(1)
ToggleProtectDocument
If ActiveDocument.FormFields(FormfieldName()).CheckBox.Value = True Then
oCell.Range.Font.Color = wdColorBlack
Else
oCell.Range.Font.Color = wdColorWhite
End If
ToggleProtectDocument
End Sub
Sub ToggleProtectDocument()
If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
ActiveDocument.Unprotect
ElseIf ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True
End If
End Sub
Function FormfieldName() As Variant
If Selection.FormFields.Count = 1 Then
FormfieldName = Selection.FormFields(1).Name
ElseIf Selection.FormFields.Count = 0 And Selection.Bookmarks.Count > 0
Then
FormfieldName = Selection.Bookmarks(Selection.Bookmarks.Count).Name
End If
End Function
---------------------------------------------------------------------------------------------------------------------
Hope this helps,
regards,
Astrid
So that all can benefit from the discussion, please post all follow-ups to
the newsgroup.
Visit the MVP Word FAQ site at
http://www.mvps.org/word/