6

Is it possible to use conditional formatting in Microsoft Word 2007 Mail merge? I would like it to color the font, depending on the field value, for instance:

  • if "Priority" field equals 1, color the font to red
  • if "Priority" field equals 2, color the font to yellow
  • if "Priority" field equals 3, color the font to green

I've tried using the "Rules" -> "If... Then... Else" and this could probably work, but creating rules using it is a nightmare.... Is there a better way?

2 Answers2

3

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

Glorfindel
  • 4,158
Adam
  • 7,669
1

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.