color in a text box

R

rutica

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,
 
G

Graham Mayor

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

Doug Robbins - Word MVP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top