View Single Post
 
Old 08-28-2016, 03:31 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

To colour the text & background so they're the same, you could use:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Const StrPwd As String = "abc"
With ContentControl
  Select Case .Title
    Case "Lst1", "Lst2"
      If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect Password:=StrPwd
      With .Range
        Select Case .Text
          Case "High"
            .Cells(1).Shading.BackgroundPatternColorIndex = wdRed
            .Font.ColorIndex = wdRed
          Case "Medium"
            .Cells(1).Shading.BackgroundPatternColorIndex = wdYellow
            .Font.ColorIndex = wdYellow
          Case "Low"
            .Cells(1).Shading.BackgroundPatternColorIndex = wdBrightGreen
            .Font.ColorIndex = wdBrightGreen
          Case Else
            .Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
            .Font.ColorIndex = wdAuto
        End Select
      End With
      ActiveDocument.Protect wdAllowOnlyFormFields, True, StrPwd
  End Select
End With
End Sub
Regarding your file type, do be aware that docx files cannot contain macros. You will need to use either: a docx file attached to a template containing the macro; or a docm file.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]