#1
|
|||
|
|||
How to change font and background colors based on Combo Box selection
I have a combo box that I've added to a Word 2010 document and have populated it already with the options - "Critical" , "High" , "Medium", "Low". Once a user makes their selection from this list, I'd like to change the font color and background color within the combo box as follows:
Critical = Red background / White font High = Orange background / Black font Medium = Yellow background / Black font Low = Green background / White font I'm sure that this is not the first time this topic has been discussed, however, I am not sure exactly how to add the code to the combo box, so I apologize upfront for the redundant thread. If there is currently code available that I can tweak to fit my color scheme, then great, some help on how to add it to the combo box would be very helpful as well. |
#2
|
||||
|
||||
See, for example: https://www.msofficeforums.com/word-...html#post47254
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
If it is a content control you have to use the OnExit event in the ThisDocument module;
Code:
Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean) Select Case CC.Range.Text Case "Critical" CC.Range.Shading.BackgroundPatternColorIndex = wdRed CC.Range.Font.ColorIndex = wdWhite Case "Medium" CC.Range.Shading.BackgroundPatternColorIndex = wdYellow CC.Range.Font.ColorIndex = wdBlack Case "Low" CC.Range.Shading.BackgroundPatternColorIndex = wdGreen CC.Range.Font.ColorIndex = wdWhite End Select End Sub |
#4
|
|||
|
|||
Quote:
I have tried to get it to work with the content control by am not able to make it work. |
#5
|
|||
|
|||
If you put that code in the this document module of your VP project then "ANY" content control that displays "Critical, Low, or Medium" will be affected.
To narrow it down to a specific CC then add a condition to check for "Title" or "Tag" of the specific CC. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Change Background Colors in Office 2013 | boward57 | Office | 2 | 10-06-2015 06:53 PM |
text based on Combo box selection | rosscortb | Word VBA | 3 | 03-16-2015 06:57 PM |
Combo Box Content Control Calculate on selection help | ciresuark | Word | 0 | 03-06-2015 01:49 PM |
Unable to change font colors from theme colors | choy | Word | 3 | 08-01-2012 09:12 PM |
How can I change the colors of cells automatically based on Job Completion? | Learner7 | Excel | 0 | 07-06-2010 10:47 PM |