Conditional Formatting in a mail merge (Word 2010)

Hi there

I've tried to find similar answers but my request is very specific....

I have an excel sheet that I am putting into a labels mail merge where one column in the Excel has the input of either Green, Yellow, Red or Blue. (I have made the spreadsheet then auto change to the appropriate colour with conditional formatting)

I know this doesn't keep for the mail merge.... so my questions are...

1) Can I make the word document then change that field in the mail merge to the right colour i.e. make Green turn actually Green and so on.

2) If it's possible using code _I've seen people say something like this.... Changing the colours of part of it to the right colour

{ IF { MERGEFIELD Fieldname } = "Green" "{ MERGEFIELD Fieldname \*Charformat }" = "Red" "{ MERGEFIELD Fieldname \*Charformat }" = "Yellow" "{ MERGEFIELD Fieldname \*Charformat }" = "Blue" "{ MERGEFIELD Fieldname \*Charformat }""{ MERGEFIELD Fieldname \*Charformat }" }

where do I enter this code on the mail merge if that's what I need to do?.... and would I have to do it in every label.

3) If any of this is possible what I really would like to do is make the writing black and have it highlighted in the corresponding colour. Is this possible to do?

Hopefully that all makes sense and you can help me with my query :-)

Thanks :-)

Answer
Answer

The IF fields (four of them, one for each color) should go where you want the merge field to appear. You'll probably have to hand-code them, as Word makes it unnecessarily difficult to do this through the mail merge UI. You'll need to press Ctrl+F9 for each pair of field braces. I see that (because I was typing these), I omitted one: the shaded example should be:

{ IF { MERGEFIELD Fieldname } = "Green" "{ MERGEFIELD Fieldname }" }

If the content of the COLOUR_TEAM field is Red, Green, Yellow, or Blue, and "Red," "Green," "Yellow," or "Blue" is what you want to put on the label, then you can use the syntax in the first example; there's no need for another merge field because the content of the field is already known thanks to the IF condition. That is, if COLOUR_TEAM meets the condition = "Green," and you want to print the content of the field, then you already know the text is "Green," and the only reason you're using the IF field is to apply the formatting.

Now if, as I am beginning to suspect, you want the entire content of the label to be shaded in the appropriate color, then you'll need to cram all the merge fields into your TrueText, with shading. The easiest way to do this is to insert all the needed merge fields first, then cut or copy them. Then set up your four IF fields and paste in the Clipboard contents and apply the shading.

This can be very difficult to do in the space of a small label, so you might experiment with doing it in another document (a mail merge set up as a Letter, for example), and then copy/paste the result into your mail merge main document. You won't be able to see all the field codes in the label space, but when you merge, you should get the desired result.

What you won't get with this method is an entire label shaded with the appropriate color (just the text on the label). In order to do that, you'd have to apply the shading to the label cell, and I don't know how to do that.

Microsoft MVP (Word) since 1999
Fairhope, Alabama USA
http://ssbarnhill.com
http://wordfaqs.ssbarnhill.com
Screen shots captured with TechSmith's Snagit

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 6,835 Applies to: