View Single Post
 
Old 09-14-2020, 03:21 AM
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

You already have sample code but if you want a working sample, then you need to add a Dropdown Content Control titled "EmploymentType". Give it three entries for "Full time", "Part time" and "Casual"

Then select the text that only appears if Full time is selected and click the Plain Text CC button on your Developer Tab. Change the title of that CC to "Full time". Do the same for any other instances that need to be visible when Full time is selected.

Do the same for the Part time and Casual sections of text.

Put this code in your ThisDocument module.
Code:
Private Sub Document_ContentControlOnExit(ByVal myCC As ContentControl, Cancel As Boolean)
  Dim aCC As ContentControl, sET As String
  If myCC.Title = "EmploymentType" Then
    sET = myCC.Range.Text
    For Each aCC In ActiveDocument.ContentControls
      aCC.Range.Font.Hidden = aCC.Title <> sET  'hide if CC title doesn't match selected employment type
    Next aCC
  End If
End Sub
Save the document as docm or dotm. You should be able to make a selection on the dropdown CC and see the changes as soon as you move your selection out of that CC.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote