View Single Post
 
Old 12-18-2017, 04:30 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

See: https://www.msofficeforums.com/word-...html#post47254

As for your code (which isn't what you have in the attachment), a test like:
If Left(.Title, 4) = "Severity" Then
will never work, since "Severity" has more than 4 characters. There are other errors in your code, too.

Try:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
With ContentControl
  If .Title = "Risk" Then
    Select Case .Range.Text
      Case "High": .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdRed
      Case "Moderate": .Range.Cells(1).Shading.BackgroundPatternColor = RGB(255, 192, 0)
      Case "Critical": .Range.Cells(1).Shading.BackgroundPatternColor = RGB(192, 0, 0)
      Case Else: .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
    End Select
 ElseIf .Title = "Severity" Then
    Select Case .Range.Text
      Case "R": .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdRed
                     .Range.Cells(1).Range.Font.Color = wdRed
      Case "Y": .Range.Cells(1).Shading.BackgroundPatternColor = RGB(255, 192, 0)
                     .Range.Cells(1).Range.Font.Color = RGB(255, 192, 0)
      Case "DR": .Range.Cells(1).Shading.BackgroundPatternColor = RGB(192, 0, 0)
                       .Range.Cells(1).Range.Font.Color = RGB(192, 0, 0)
      Case "G": .Range.Cells(1).Shading.BackgroundPatternColor = wdGreen
                   .Range.Cells(1).Range.Font.Color = wdGreen
      Case "BG": .Range.Cells(1).Shading.BackgroundPatternColor = wdBrightGreen
                    .Range.Cells(1).Range.Font.Color = wdBrightGreen
      Case Else: .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
    End Select
  End If
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote