Forum Discussion

Brad_Docimo's avatar
Brad_Docimo
Copper Contributor
Jun 28, 2026
Solved

Dynamic Pages in Mail Merge

Is there any way to dynamically turn pages in a document on or off during a mail merge?

Building a welcome packet for an event, and some people need to see Page A.  Others need to see Page B instead.  If it were just simple text differences between the two, I could merge in the content itself, but the pages are wildly different, with images and other elements.

Thanks

  • Yes Absolutely but here is main point you should understand it first ,Word can not toggle whole pages itself  but an If field paired with include text gets you there. Save page A and Page B as separate documents so the images and layout stay intact, add a column like Packet type A and B to your data source, then in the merge doc press ALT+F9 and set up a conditional that checks that column and pulls in the matching file. Keeping each page in its own file is what worked for me, since images get unpredictable when you cram both pages into one IF field. Built and proof each page on its own first, then wire up the merge last.

8 Replies

  • Brad_Docimo's avatar
    Brad_Docimo
    Copper Contributor

    Include text worked for me.  I did find that none of the previews in the Word merge tool worked unless I went to that individual record, selected all, then pressed F9.  And had to do that on every record, but when printing to PDF (which is what I actually need), they all seem to work.

    { IF "{ MERGEFIELD TestField}" = "A" { INCLUDETEXT "c:\\mypath\\myfileA.docx" } { INCLUDETEXT "c:\\mypath\\myfileB.docx" } }

    Thanks!

  • Brad_Docimo's avatar
    Brad_Docimo
    Copper Contributor

    Unfortunately, this did not work for me.  The IF statement works, and will swap out text, but as soon as I switch to {AutoText Name} it only returns blanks.

     

  • saleha15's avatar
    saleha15
    Tin Contributor

    Yes, it's possible, but it depends on the mail merge tool you're using.

    If your platform supports conditional content or document sections, you can use a field (e.g., PacketType) to determine which page is included. For example, recipients with PacketType = A receive Page A, while those with PacketType = B receive Page B.

    If your mail merge solution doesn't support conditional pages, a few alternatives are:

    • Create two separate templates and route recipients to the appropriate one based on your data.
    • Use a document automation solution that supports conditional blocks or sections (such as Microsoft Word IF fields, Google Docs add-ons with conditional logic, or dedicated document generation tools).
    • Generate the documents programmatically using a scripting or document automation platform if you need more flexibility.

    Could you share which mail merge tool you're using (Microsoft Word, Google Docs, Outlook, Mail Merge for Gmail, etc.)? That will help determine the best approach.

  • Charles_Kenyon's avatar
    Charles_Kenyon
    Bronze Contributor

    I would save the content for Page A as an AutoText entry and for Page B as a separate entry.

    Have something set in your data to distinguish these separate groups (i.e. a separate data point in the records).

    Then use an IF field to test and display with an AUTOTEXT field for the result.

    Something like:

    { IF "{MergeField Test }"="A" "{AutoText PageA }" "{AutoText PageB }" }

  • Yes Absolutely but here is main point you should understand it first ,Word can not toggle whole pages itself  but an If field paired with include text gets you there. Save page A and Page B as separate documents so the images and layout stay intact, add a column like Packet type A and B to your data source, then in the merge doc press ALT+F9 and set up a conditional that checks that column and pulls in the matching file. Keeping each page in its own file is what worked for me, since images get unpredictable when you cram both pages into one IF field. Built and proof each page on its own first, then wire up the merge last.