![]() |
|
#1
|
||||
|
||||
![]()
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] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
spk | Word VBA | 43 | 07-31-2022 03:51 PM |
![]() |
LaurenM | Word VBA | 9 | 11-22-2017 11:46 PM |
![]() |
coconutt | Word VBA | 5 | 09-13-2012 05:23 PM |
![]() |
fedcco | Excel | 12 | 08-28-2012 10:43 PM |
Change cell color everytime a value is selected in dropdown list | angelica_gloria | Excel | 4 | 01-27-2012 06:47 PM |