View Single Post
 
Old 08-11-2021, 05:23 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

OK, do a SaveAs on that file and change the type to docm

Set the Title Property of the first CC to 'Interested"
Set the Title Property of the second CC to "Explain"

Add the following macro to the ThisDocument module in the file
Code:
Private Sub Document_ContentControlOnExit(ByVal thisCC As ContentControl, Cancel As Boolean)
  Dim aCC As ContentControl, bHide As Boolean
  
  If thisCC.Title = "Interested" Then
    bHide = thisCC.Range.Text = "No"
    'bHide = Not thisCC.Range.Text = "Yes"   'this alternative treats a non-selection differently
  End If
  
  'Change the hidden property on the dependent CC paragraph
  For Each aCC In ActiveDocument.SelectContentControlsByTitle("Explain")
    aCC.Range.Paragraphs(1).Range.Font.Hidden = bHide
  Next aCC
  
  'Ensure hidden text is not visible on screen
  With ActiveWindow.View
    .ShowHiddenText = False
    .ShowAll = False
  End With
End Sub
Then change the value in the dropdown and move the cursor out of the CC.

Note that I put two alternatives for bHide in the code. You can enable or disable these lines by adding/removing the ' from the start. The difference is how it treats the top option ie blank.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote