How can I suppress a page in Mailmerge on condition of an Excel value ?

Hi Experts,

I have a Word document consisting of two pages (an Invoice, and a Balance Statement) which I use to MailMerge invoice data from an Excel worksheet. It works fine, generating both pages for each Excel row.

However, I would like it to only create the Balance Statement (the second of the two pages) if the value in a 'Balance Due' field in the spreadsheet exceeds £500. is it possible to suppress a page in Word MailMerge ?

Thanks
Toco
TocogroupAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
You can use an IF field.

Show the formatting marks with the Show/Hide (¶) button and show the field codes using the Alt+F9 toggle. Select the page in question, and hit Ctrl+F9. This will embed the page in a pair of field delimiters that look like curly brackets. Put a set of double quotes just inside each of the brackets. In draft view it should look something like this:

{ "................Page Break.................¶
Balance Date: { MERGEFIELD BalanceDate }¶
Balance Due: { MERGEFIELD Balance_Due }" }¶

Just inside the first field delimiter insert IF , the 'balance due' Mergefield and the test, so that it now looks like this:

{ IF { MERGEFIELD Balance_Due } > 500 "................Page Break.................¶
Balance Date: { MERGEFIELD BalanceDate }¶
Balance Due: { MERGEFIELD Balance_Due }" }¶

You can revert to showing field results with Alt+F9, but the mergefields in the IF field will not be visible.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TocogroupAuthor Commented:
Thanks for your help Graham.

I followed your instructions up to the point where I embedded the page within curly braces but without adding the IF{MERGEFIELD statement.

{ "................Page Break.................¶

I then tried the MailMerge to confirm that it would still work with the curly braces. But it didn't ! It didn't generate the second page at all.

Why is this ? Does it need the IF statement to print the second page ?
Regards
Toco



Open in new window

TocogroupAuthor Commented:
Thanks for the excellent solution Graham. I got it to work eventually - the spaces were important !

Toco
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.