Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-03-2013, 09:45 AM
pgammag pgammag is offline Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Windows XP Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Office 2003
Novice
Conditionally Color Formatting Text selected from a dropdown list in Word 2010
 
Join Date: Oct 2013
Posts: 2
pgammag is on a distinguished road
Question Conditionally Color Formatting Text selected from a dropdown list in Word 2010

I have a very simple status report that contains a drop down list created using developer in Word2010. The options are Normal, Caution, Alert.



Is there a way for the color of the text to change based on the selection? For example, if "Normal" is selected, then change to green, if "Caution" is selected, then change to yellow, if "Alert" is selected, then change to red.

I know it's possible to change a mergefield text color, but not sure how that would translate to a drop down list. I'd like to do this without inserting an Excel object or by using VBA code.

Additionally, if I put the drop down list into a cell in a table, would it be possible to change the cell color based on the selection in the drop down list?
Reply With Quote
  #2  
Old 10-03-2013, 02:26 PM
macropod's Avatar
macropod macropod is offline Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Windows 7 32bit Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Using Word 2003 (as per your profile), you could only do that kind of thing with a macro attached to the formfield's 'on exit' property. See attached.
Attached Files
File Type: doc Formfields - Dropdown Conditional Format.doc (44.0 KB, 576 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 02-26-2014, 03:53 AM
Shar Shar is offline Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Windows 7 32bit Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Office 2010 32bit
Novice
 
Join Date: Feb 2014
Posts: 1
Shar is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
You could only do that kind of thing with a macro attached to the formfield's 'on exit' property. See attached.
Hi,

I'm looking for the very same thing and your example is precisely what I'm looking to do. Can you possibly share HOW you did this? I'm relatively experienced with Word but this is far more advanced than I ever needed to be before now.

Thanks for your help!

Shar
Reply With Quote
  #4  
Old 02-26-2014, 04:44 AM
macropod's Avatar
macropod macropod is offline Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Windows 7 32bit Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

It's all done via the macro attached to the formfield's 'on exit' property. To see the code, unprotect the document then press Alt-F11 to open the VBA IDE.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 02-26-2014, 07:54 AM
pgammag pgammag is offline Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Windows XP Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Office 2003
Novice
Conditionally Color Formatting Text selected from a dropdown list in Word 2010
 
Join Date: Oct 2013
Posts: 2
pgammag is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
It's all done via the macro attached to the formfield's 'on exit' property. To see the code, unprotect the document then press Alt-F11 to open the VBA IDE.

I was hoping not to use any code if possible since it would not be allowed to run when others open it up in our company.
Reply With Quote
  #6  
Old 02-26-2014, 02:04 PM
macropod's Avatar
macropod macropod is offline Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Windows 7 32bit Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Word has no facility for automatically conditionally formatting a table cell. Consequently, a macro is required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 03-20-2014, 05:17 PM
Atodd87 Atodd87 is offline Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Windows 7 32bit Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Office 2010 32bit
Novice
 
Join Date: Mar 2014
Posts: 1
Atodd87 is on a distinguished road
Default

I wouldn't call this issue solved. I'm wondering the same thing, and not everyone is a computer programmer who can simply format the VBA code...

Any instruction on how to do this?
Reply With Quote
  #8  
Old 03-20-2014, 05:38 PM
macropod's Avatar
macropod macropod is offline Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Windows 7 32bit Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

The thread is marked as solved because it solved the OP's issues. Your opinion nearly a year later doesn't change that.

Have you looked at the attachment and the macro code in it? What instruction do you need? What are you trying to achieve beyond what the code in the attachment does?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 08-20-2019, 03:01 PM
GDaddy35803 GDaddy35803 is offline Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Windows 10 Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Office 2019
Novice
 
Join Date: Aug 2019
Posts: 1
GDaddy35803 is on a distinguished road
Default Need help with colorcoding a drop down list

Hello Paul,

I tried to do as you instructed but can't seem to see the code in your attachment.

I am not a coder, but this is what I am looking to do: make a drop down list in Word [done] but when I pick a word "Critical, High, Medium, Low, None" I want it displayed in the colors below. When I run the below VBScript they all display green. I copied this code off the internet and it change the whole cell one of the colors, but I just want the text. So what does the last line need to be as well?

Code:
With ContentControl.Range
    If ContentControl.Title = "Severity" Then
        Select Case .Text
            Case "Critical"
                .Attributes.Add("style", "color:Dark Red")
            Case "High"
                .Attributes.Add("style", "color:Red")
            Case "Medium"
                .Attributes.Add("style", "color:Orange")
            Case "Low"
                .Attributes.Add("style", "color:Blue")
            Case "None"
                .Attributes.Add("style", "color:Green")
            Case Else
                .Cells(1).Shading.BackgroundPatternColor = wdColorAutomatic
        End Select
    End If
End With
End Sub
Reply With Quote
  #10  
Old 08-20-2019, 04:17 PM
macropod's Avatar
macropod macropod is offline Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Windows 7 64bit Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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 the code for Content Control Conditional Formatting in the attachment at: Change color according with dropdown selection. To vary the text colour rather than the cell colour, change:
Code:
.Range.Cells(1).Shading.BackgroundPatternColorIndex
to:
Code:
.Range.Font.ColorIndex
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
conditional formatting, drop down lists, word 2010

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA: How to place dropdown list next to text YigalB Word VBA 0 08-11-2013 01:48 PM
Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Formatting affecting more than selected text esteban Word 7 05-25-2012 04:34 AM
Change cell color everytime a value is selected in dropdown list angelica_gloria Excel 4 01-27-2012 06:47 PM
Conditionally Color Formatting Text selected from a dropdown list in Word 2010 Strange formatting text color error in form fields.. rscafidi Word 2 10-16-2011 03:25 PM
Text form field loses formatting in Word 2010 mel72349 Word 0 08-02-2011 02:25 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:52 PM.


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