Word mailmerge dynamically set color

Posted on 2012-09-03
Last Modified: 2013-08-29

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.
Question by:arthrex
    LVL 50

    Expert Comment


    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
    LVL 76

    Accepted Solution

    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.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
    The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now