View Single Post
 
Old 04-20-2021, 01:59 PM
GoChatter GoChatter is offline Windows XP Office 2016
Novice
 
Join Date: Apr 2021
Posts: 2
GoChatter is on a distinguished road
Question How to change VB code so dropdown conditional format color changes to "wdLightOrange"

I am trying to figure out how to insert a dropdown list (Choose Item: High, Medium, low) into a report table in MS Word. I need High to = wdRed, Medium to = wdLightOrange (Hex: #FF9900), and Low to = wdYellow. I found the following code:
in a file named "Content Controls - Dropdown Conditional Format.docm" that I found from the 'macropd' Administrator, Paul Edstein URL: https://www.msofficeforums.com/word-...html#post47254

Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
With ContentControl
  If Len(.Title) < 4 Then Exit Sub
  If Left(.Title, 4) = "Risk" Then
    Select Case .Range.Text
      Case "High": .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdRed
      Case "Medium": .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdYellow
      Case "Low": .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdBrightGreen
      Case Else: .Range.Cells(1).Shading.BackgroundPatternColorIndex = wdNoHighlight
    End Select
  End If
End With
End Sub
In Paul's document, I successfully changed the Low from "wdBrighGreen" to "wdYellow" but when I try to replace the Medium from "wdYellow" to "wdLightOrange", it breaks the code. The following text is highlighted in bright yellow with an arrow next to it): "Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)"

What do I need to do to get my table to highlight with Light orange (HEX: #FF9900) when I select the Medium from the form field drop down box?

Am attaching the one I downloaded from Paul Edstein and the one I am working on.

Last edited by macropod; 04-20-2021 at 02:27 PM. Reason: Added code tags
Reply With Quote