Thread: [Solved] Checkbox Highlight Option
View Single Post
 
Old 04-13-2022, 04:10 PM
Cire Cire is offline Windows 10 Office 2019
Novice
 
Join Date: Apr 2022
Posts: 1
Cire is on a distinguished road
Talking

Quote:
Originally Posted by Guessed View Post
I would set up the document so that the title of the CC is the same as the bookmark name. Then you wouldn't need a massive series of code to deal with every specific pairing of CC to bookmarked range.
Code:
Private Sub Document_ContentControlOnExit(ByVal aCC As ContentControl, Cancel As Boolean)
  Dim sName As String, lColour As Long
  If aCC.Type = wdContentControlCheckBox Then
    If aCC.Checked Then
      lColour = wdYellow
    Else
      lColour = wdNoHighlight
    End If
    sName = Replace(aCC.Title, " ", "")         'bookmark names can't have spaces
    If ActiveDocument.Bookmarks.Exists(sName) Then
      ActiveDocument.Bookmarks(sName).Range.HighlightColorIndex = lColour
    End If
  End If
End Sub
Work like a charm! Thank you very much!
Reply With Quote