Microsoft word - conditional formatting in mail merge?

Using If..Then..Else is the right start as it inserts an IF field into the document which is what you need, however the dialog which comes up isn't powerful enough to do this kind of thing so you will need to edit the IF fields manually in the document.

What you will need to have is IF fields which compare the value of the field and will display the field with desired color for the appropriate value. Don't forget the MERGEFORMAT switch so that this color is passed on to the merged text.

enter image description here


Normally you would need the { IF } as suggested by Adam, or you can use separate IF fields rather than nested ones if the test values are mutually exclusive.

Either way, trying to insert nested fields using the built-in dialogs can be difficult. It's usually simpler to work with the field code shortcut keys and enter them manually - on WIndows Word, ctrl-F9 to insert a pair of the special field code braces, alt-F9 to toggle between field code view and results view, F9 to update selected fields and so on.

In the specific case where there are three values to test, the text to be coloured is short and contains no single quote characters, then you could consider using something like this:

{ ={ MERGEFIELD Priority }-2 \#"'priority 3 text';'priority 1 text';'priority 2 text'" }

Then you apply the appropriate colour to each text.

The length limitation is that the text between the "" cannot exceed 64 characters.

You can bring the text in from a merge field by nesting the appropriate merge field, but the same limitations on single quote characters and total length apply.