Word mailmerge dynamically set color

Hello,

I have a mail merge template which is supposed to fill the background of the document with a specific colour that is dynamically calculated by certain fields of the excel source.

I.e. if field "country" eq "Germany" then display background in green.
"Country" eq "Spain" display background in red.

Is that possible?
Any help is greatly appreciated.
arthrexAsked:
Who is Participating?
 
GrahamSkanRetiredCommented:
A single mail merge operation to a result document produces only the one document. Page background colour applies to the whole document, so even if Word Field logic could apply a background colour it couldn't provide the different colours required.

If your skill level is sufficient for future maintenance, it would be possible to run the merge as separate merges under VBA control, so that the code would colour each output document individually.
0
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Hello,

as far as I know, you cannot set the background colour of a Word document based on the value of a mail merge field.

You CAN set the colour of the text of in a mail merge document by creating an IF statement along the lines of

{ IF {mergefield MyField} = "this" "This text" "That text"}

Inside the IF statement you can format "This text" and "That text" to have different formatting, like font, colour, paragraph background, etc.

The document background is on a different level, though.

You may want to use a separate merge document for each different background colour and then filter the data source by the country field, so the "green" merge document only receives the records for "Germany" and the "red" merge document only receives the records for "Spain".

cheers, teylyn
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.