Home |
Search |
Today's Posts |
#1
|
|||
|
|||
color in a text box
Hello,
I have a Word 2003 text box that is a Merge field from Excel. I would like the Fill Color of the text box to change depending on the value of the box. (The values can be only Red, Yellow, Green or Purple). This is what I tried: { IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "Red" Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 0, 0) } { IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "Yellow" Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 0) } etc But that is not the right format. Help! Thanks, Last edited by rutica : May 16th 09 at 03:36 AM |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
color in a text box
You cannot mix vba language and field constructions in this way. What you
can do is conditionally insert the text box eg { IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "Red" "Put the red text box here" }{ IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "Yellow" "Put the yellow text box here" }{ IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "Green" "Put the green text box here" }{ IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "Purple" "Put the purple text box here" }{ IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "" "Put the empty text box here" } See also http://www.gmayor.com/SelectFile.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org rutica wrote: Hello, I have a Word 2003 text box that is a Merge field from Excel. I would like the Fill Color of the text box to change depending on the value of the box. (The values can be only Red, Yellow, Green or Purple). That is what I tried: { IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "Red" Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 0, 0) } { IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "Yellow" Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 0) } etc But that is not the right format. Help! Thanks, |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
color in a text box
As you have discovered, mixing fields and vba commands does not work. I am
pretty sure that the only way to do what you want is to use VBA to interrogate the data source and then use VBA code to set the fill color of the text box. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "rutica" wrote in message ... Hello, I have a Word 2003 text box that is a Merge field from Excel. I would like the Fill Color of the text box to change depending on the value of the box. (The values can be only Red, Yellow, Green or Purple). That is what I tried: { IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "Red" Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 0, 0) } { IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "Yellow" Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 0) } etc But that is not the right format. Help! Thanks, -- rutica |
#4
|
|||
|
|||
Thanks for writing.
Graham, I'm not sure what you meant by "Put the red text box here" in your response: { IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "Red" "Put the red text box here" } ... I don't know how to put the red text box there. I looked at your link, but I'm not too familiar with VBA in Word. I decided to simplify and change the color of the words instead of the text box. This is my code: { If { MERGEFIELD "Risk_Issue_KPI_Score" } = Red "Red" }{ If { MERGEFIELD "Risk_Issue_KPI_Score" } = Yellow "Yellow" }{ If { MERGEFIELD "Risk_Issue_KPI_Score" } = Green "Green" }{ If { MERGEFIELD "Risk_Issue_KPI_Score" } = Purple "Purple" } You can't tell from above since I can't add color to this forum, but the color words in quotes are actually in that color. Ex: "Red" is actually written in red font in my Word Document. "Yellow" is actually written in yellow font, etc. And that works. It's not exactly what I wanted though. Thanks again! Quote:
|
#5
|
|||
|
|||
Thanks for writing.
Graham, I'm not sure what you meant by: "put the red text box here" in your code: { IF { MERGEFIELD "Risk_Issue_KPI_Score" } = "Red" "Put the red text box here" }"... I don't know how to do that. But I decided if I can't make the text box change color, I made the font color change: { IF { MERGEFIELD "Risk_Issue_KPI_Score" } = Red "Red" }{ IF { MERGEFIELD "Risk_Issue_KPI_Score" } = Yellow "Yellow" } etc. You can't tell from above since I can't use color in this forum, but my "Red" is written in red font. The "Yellow" is written in yellow font, etc. Thanks! Quote:
|
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can you vary the strikethrough color without changing text color | Microsoft Word Help | |||
Word should allow strikethrough color different than text color | Microsoft Word Help | |||
How do I make my black text single color black not 4 color black? | Microsoft Word Help | |||
when i change text color, some of the other text prints bold.help | Microsoft Word Help | |||
How Format Painter could copy the font color of a color text? | Microsoft Word Help |