View Single Post
 
Old 09-29-2020, 08:43 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,989
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

Try this code instead. If you want subtle changes in colour to show text on a pastel background you need to use RGB values rather than sticking with limits of the built-in Word variables.
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  Const StrPwd As String = "abc"
  With ContentControl
    Select Case .Title
      Case "Bondy Scale"
        If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect Password:=StrPwd
        With .Range
          .Cells(1).Shading.Texture = wdTextureNone
          Select Case .Text
            Case "Dependent", "Marginal"
              .Cells(1).Shading.BackgroundPatternColor = RGB(255, 109, 109)
              .Font.Color = wdColorRed
            Case "Assisted"
              .Cells(1).Shading.BackgroundPatternColor = RGB(255, 183, 67)
              .Font.Color = RGB(255, 160, 0)
            Case "Supervised", "Independent"
              .Cells(1).Shading.BackgroundPatternColor = wdColorLightGreen
              .Font.Color = wdColorBrightGreen
            Case Else
              .Cells(1).Shading.BackgroundPatternColor = wdColorWhite
              .Font.ColorIndex = wdAuto
            End Select
          End With
      ActiveDocument.Protect wdAllowOnlyFormFields, True, StrPwd
    End Select
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote