Conditional Pagebreaks in Mailmerge

Discussion in 'Word' started by Archie, Apr 23, 2018.

  1. Archie

    Archie

    Joined:
    Apr 23, 2018
    Messages:
    2
    Likes Received:
    0
    Hello, I'm new to mailmerge and I'm trying to print a documents and add a Pagebreak under program control.
    I tried writing the Formfeed character (ascii "12") into the document but this has no effect.

    I read elsewhere that I can add something like the below in the template:

    {IF {Mergefield Pagebreak} = "True" "pagebreak here"}

    I actually typed this into the "Field code":
    IF {MERGEFIELD Pagebreak} = "True" "x" ""

    Hoping that I'd be able to "Inset a pagebreak" manually hoping that on on returning to the document I'd see an "x" that I could replace with a pagebreak, but instead I see
    "Pagebreak}"

    no longer <<Pagebreak>> as it was when it was a simple "mergeField"

    Perhasp all I need is some tuition in creating merge templates...so can either somebody tell me where to go, or what to do?

    Thanks
     
    Archie, Apr 23, 2018
    #1
    1. Advertisements

  2. Archie

    Archie

    Joined:
    Apr 23, 2018
    Messages:
    2
    Likes Received:
    0
    OK, managed to do this by playing with the syntax a little....and just in case somebody else comes along with the same level of knowledge & a similar requirement...

    In the program, I write either a null or a space into the mergefield.

    In the template, all curly brackets created by typing Ctrl F9.
    Codes were made visible/invisible by toggling via Alt F9).

    I added the Mergefield "Pagebreak" with the following:

    {MERGEFIELD Pagebreak}

    and the following code compares the mergefield "Pagebreak" with a space (" ") & if it finds it, prints a formfeed (QUOTE 12) else prints NULL - i.e. Syntax: IF condition truechar falsechar:

    {IF {MERGEFIELD Pagebreak} = " " "{QUOTE 12}" ""}

    I chose to print the formfeed depending on a value of space or null because I needed a non-printing character...perhaps I could have defined a field so that it doesn't print in any case?
     
    Archie, Apr 23, 2018
    #2
    1. Advertisements

  3. Archie

    macropod Microsoft MVP

    Joined:
    Mar 2, 2012
    Messages:
    394
    Likes Received:
    35
    Using {QUOTE 12} is fairly conventional, though you could insert an actual page break or next page section break into your field code instead. FWIW, your existing field code could be reduced to:
    {IF{MERGEFIELD Pagebreak}= " " {QUOTE 12}}
    Without knowing more about why you're using such a field, though, it's impossible to advise more on your 'perhaps I could have defined a field so that it doesn't print in any case' question.
     
    macropod, Apr 23, 2018
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.