Reply
 
Thread Tools Display Modes
  #1   Report Post  
rutica rutica is offline
Junior Member
 
Posts: 14
Default 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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default 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   Report Post  
rutica rutica is offline
Junior Member
 
Posts: 14
Default

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:
Originally Posted by Doug Robbins - Word MVP View Post
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
  #5   Report Post  
rutica rutica is offline
Junior Member
 
Posts: 14
Default

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:
Originally Posted by Doug Robbins - Word MVP View Post
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
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you vary the strikethrough color without changing text color Linmark10 Microsoft Word Help 2 December 16th 08 12:22 AM
Word should allow strikethrough color different than text color Robert Highley Microsoft Word Help 0 November 12th 08 09:50 PM
How do I make my black text single color black not 4 color black? Lara Go Microsoft Word Help 2 August 25th 06 07:01 PM
when i change text color, some of the other text prints bold.help tiff Microsoft Word Help 0 July 24th 06 04:08 PM
How Format Painter could copy the font color of a color text? Miksmith69 Microsoft Word Help 1 August 27th 05 06:43 PM


All times are GMT +1. The time now is 12:34 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"