Microsoft Office Forums How to change font and background colors based on Combo Box selection

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2016, 09:26 AM
KMan3210 KMan3210 is offline How to change font and background colors based on Combo Box selection Windows 10 How to change font and background colors based on Combo Box selection Office 2010 32bit
Novice
How to change font and background colors based on Combo Box selection
 
Join Date: Dec 2016
Posts: 2
KMan3210 is on a distinguished road
Talking 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.
Reply With Quote
  #2  
Old 12-05-2016, 04:15 PM
macropod's Avatar
macropod macropod is offline How to change font and background colors based on Combo Box selection Windows 7 64bit How to change font and background colors based on Combo Box selection Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,575
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

See, for example: https://www.msofficeforums.com/word-...html#post47254
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 12-05-2016, 04:19 PM
gmaxey gmaxey is offline How to change font and background colors based on Combo Box selection Windows 7 32bit How to change font and background colors based on Combo Box selection Office 2016
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 958
gmaxey will become famous soon enoughgmaxey will become famous soon enough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #4  
Old 12-06-2016, 09:36 AM
KMan3210 KMan3210 is offline How to change font and background colors based on Combo Box selection Windows 10 How to change font and background colors based on Combo Box selection Office 2010 32bit
Novice
How to change font and background colors based on Combo Box selection
 
Join Date: Dec 2016
Posts: 2
KMan3210 is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
If it is a content control you have to use the OnExit event in the ThisDocument module;

[/CODE]
Thanks gmaxey, now how do i assign it or get it to work with the Combo Box Content Control or Drop-Down List Content Control?

I have tried to get it to work with the content control by am not able to make it work.
Reply With Quote
  #5  
Old 12-06-2016, 10:11 AM
gmaxey gmaxey is offline How to change font and background colors based on Combo Box selection Windows 7 32bit How to change font and background colors based on Combo Box selection Office 2016
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 958
gmaxey will become famous soon enoughgmaxey will become famous soon enough
Default

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.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change font and background colors based on Combo Box selection 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
How to change font and background colors based on Combo Box selection 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


All times are GMT -7. The time now is 04:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft