none
Conditional Mergefields in Footer don't work as expected RRS feed

  • Question

  • Greetings,

    I have what seems a strange problem:

    I am generating a (Catalog) merge document. For some of the entries I insert a notation, and on those pages I add a footnote; the pages with no notations get no footnote.

    The general scheme is:

    { IF { MERGEREC } = "1" "{ SET Gtag "-" }}
    ... various merged fields and text ...
    { IF MERGEFIELD Nt = "NT" "note text{ SET Gtag "noted" }"

    In the footer is:

    { IF { Gtag} = "noted" "footnote text here{ SET Gtag "-" }}

    The footer never prints, although notations are properly inserted.

    As a test, I printed out the value of Gtag at the end of each entry, and in the footer before the condition. I get "-" on the first entry, and "Qh" thereafter. Changing the values of Gtag to be 0|1 produces a similar result.

    Frankly, I'm stumped. I could use some insight here.

    TIA for any help,

    Zk

    Thursday, May 16, 2013 9:19 AM

Answers

  • You cannot use an IF test in a directory mailmerge header/footer to conditionally display content. The IF test will be evaluated for the first record only and the field converted to static text. You can do it in a letter merge, though, as the IF test gets re-evaluated for each record and, although the field still gets converted to static text, the Section breaks allow each record to have a separate header/footer.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by Zauberkind Friday, May 17, 2013 7:27 AM
    Thursday, May 16, 2013 11:54 PM

All replies

  • If you use a directory type mail merge, there should be a section break at the end. Without the section break, all pages in the merged document will have the same footer.

    The line

    { IF MERGEFIELD Nt = "NT" "note text{ SET Gtag "noted" }"

    should be

    { IF { MERGEFIELD Nt } = "NT" "note text{ SET Gtag "noted" }"}

    using Ctrl+F9 to insert field braces, of course.

    With this change, it works for me.


    Regards, Hans Vogelaar

    Thursday, May 16, 2013 9:45 AM
  • Thanks Hans,

    the missing { } is just a monument to my typing skills.

    You have given me something to think about, but your solution doesn't quite work. If I use a continuous section break, the flag is reset before the next page break unless the flag is set in the last entry on the page.

    Do you know when the header/footer is generated? If it's the same for each page, it seems like it must be done before the document is generated. Can you think of any way I can generate a real footnote with the reset code in it?

    The "Qh" seems to be a real problem. The actual merge code is:

    { IF { MERGEREC } = "1" "{ SET GleichTag "-" }}
     ... { IF { MERGEFIELD Gleich } = "Gleich" "symbol{ SET GleichTag "noted" }" "" } ... { GleichTag }
    
    

    If I use Gtag as the VarName, as I did in the example, everything works as expected: I get "noted" in the matching lines, and "-" in the others. If I use GleichTag, I get "-" in the first line, "noted" in the matching lines, and "Qh" in the others.

    Still seriously puzzled!

    Regards,

    Zk

    Thursday, May 16, 2013 1:14 PM
  • I have no idea where the "Qh" comes from.

    If you want to have multiple merge records on one page, it's not clear what you want to do with the footer.


    Regards, Hans Vogelaar

    Thursday, May 16, 2013 2:34 PM
  • That makes two of us...

    The records contain a flag, indicating that the record has received special treatment. The entry in the footer explains that. In case no record on the page has the flag set, there is no need for the footer paragraph.

    I can live with the footnote on every page if I have to, but it's ugly. I have been removing them manually, if for no other reason than to save paper.

    What I really want is a conditional footnote, but I can't figure out how to do that in a merge document.

    Regards, Zk

    Thursday, May 16, 2013 3:15 PM
  • That is too complex for me. Macropod (Word MVP Paul Edstein) will probably know how to do that.

    Regards, Hans Vogelaar

    Thursday, May 16, 2013 3:42 PM
  • Thanks Hans,

    I appreciate your effort.

    Regards, Zk

    Thursday, May 16, 2013 3:46 PM
  • You cannot use an IF test in a directory mailmerge header/footer to conditionally display content. The IF test will be evaluated for the first record only and the field converted to static text. You can do it in a letter merge, though, as the IF test gets re-evaluated for each record and, although the field still gets converted to static text, the Section breaks allow each record to have a separate header/footer.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by Zauberkind Friday, May 17, 2013 7:27 AM
    Thursday, May 16, 2013 11:54 PM
  • Thanks Macropod.

    That insight explains why some of my merge "magic" works in strange ways, if at all.

    The only remaining mystery is the name-dependent merge variable.

    Since I was using that to control the footer behaviour, I'll leave it for now.

    Best regards, Zk

    Friday, May 17, 2013 7:39 AM