Search code examples
ms-wordmailmerge

LISTNUM field doesn't work when the first portion of an IF statement in a mail merge


Strange behaviour observed in field codes in MS Word (2013). I have a mail merge which performs a basic IF calculation on a source data field:

{LISTNUM} Paragraph 1
{IF {MERGEFIELD ThingToCheck } = "TRUE" "{LISTNUM} Paragraph 2
" "" }{LISTNUM} Paragraph 3

When the condition is satisfied, here is what I'm expecting:

1) Paragraph 1
2) Paragraph 2
3) Paragraph 3

But strangely, here is what actually happens in the merge:

1) Paragraph 1
Paragraph 2
2) Paragraph 3

I can force the expected behavior by inserting a space between the " and the second LISTNUM field, however this throws off the indenting.

Any ideas on this one?


Solution

  • Try reversing the way you insert the paragraph marks, e.g.

    {LISTNUM} Paragraph 1{IF {MERGEFIELD ThingToCheck } = "TRUE" "
    {LISTNUM} Paragraph 2" }
    {LISTNUM} Paragraph 3
    

    That way, you have a paragraph mark before the {LISTNUM} which seems to have the same effect as a space as far as getting the {LISTNUM} to generate a number is concerned. (Only tested in Word 2010 though).