View Single Post
 
Old 11-24-2022, 06:29 AM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The following macro assumes you're using a Checkbox Content Control titled 'Checkbox1' and, for the text to be shown/hidden, a Rich Text Content Control titled 'ConditionalText':
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
With CCtrl
  Select Case .Title
    Case "Checkbox1"
      ActiveDocument.SelectContentControlsByTitle("ConditionalText")(1).Range.Font.Hidden = Not .Checked
  End Select
End With
End Sub
The code goes in the 'ThisDocument' code module of the document or its template.

With the checkbox checked, the content will be formatted as visible; unchecked, hidden. To reverse the options, delete the 'Not' from the code.

Do note that whether text formatted as hidden will remain visible - or even be printed if not visible - depends on how the user has their Word installation configured.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote