View Single Post
 
Old 02-11-2024, 06:38 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

Based on your sample doc, make changes to each of the Tag properties on the checkboxes so the Tag matches the text on the checkbox. This means each checkbox tag could be Yes, No or NA. Then try this text which will also ensure that you can only check one box at a time.
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
  Dim lngColour As Long, i As Long, aCC As ContentControl
  If CCtrl.Type = wdContentControlCheckBox Then
    If CCtrl.Checked Then
      For Each aCC In CCtrl.Range.Cells(1).Range.ContentControls
        If aCC.Tag <> CCtrl.Tag Then aCC.Checked = False
      Next aCC
      Select Case CCtrl.Tag
        Case "Yes"
          lngColour = wdGreen
        Case "No"
          lngColour = wdRed
        Case Else
          lngColour = wdAuto
      End Select
      
      CCtrl.Range.Font.ColorIndex = lngColour
      Set aCC = CCtrl.Range.Rows(1).Range.ContentControls(1)
      aCC.LockContents = False
      aCC.Range.Font.ColorIndex = lngColour
      aCC.LockContents = True
    End If
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote