Insert Conditional Paragraph in Word Merge Template

Posted on 2011-02-17
Last Modified: 2012-05-11
Is there a way to insert a blank paragraph (or in otherwords a carriage return) in a word merge temlate that is based on one of the merge fields in the document's data source meating a certain condition?  For example, I have a letter template that contains a table near the bottom representing a CC block.  The block may contain 1, 2, or many names, each separated by a carriage return.  If the count of the names exceeds 7 then the remaining names print on the next page.  What I want instead is for the tempate to remove the paragraphs immediately above the CC table so all the names move up and the letter can still exist on one page.

Thanks in advance for your response.
Question by:SueJStevens
1 Comment
LVL 50

Accepted Solution

teylyn earned 500 total points
ID: 34920345

this would be easiest if your source data contained a field with a count of the names, for example ccCount. Then you can use the {IF} field in your merge like

{ IF {MERGEFIELD ccCount} > 7 "<insert page break here>{MERGEFIELD ccName1} ¶
{MERGEFIELD ccName2} ¶
{MERGEFIELD ccName3} ¶
{MERGEFIELD ccName4} ¶
{MERGEFIELD ccName5} ¶
{MERGEFIELD ccName6} ¶
{MERGEFIELD ccName7} ¶
{MERGEFIELD ccName8} ¶
{MERGEFIELD ccName9}" "{MERGEFIELD ccName1} ¶
{MERGEFIELD ccName2} ¶
{MERGEFIELD ccName3} ¶
{MERGEFIELD ccName4} ¶
{MERGEFIELD ccName5} ¶
{MERGEFIELD ccName6} ¶
{MERGEFIELD ccName7} ¶
{MERGEFIELD ccName8} ¶
{MERGEFIELD ccName9}" }

The EE comment is not the best way to write field codes. Please do not write the {} manually, but use Ctrl-F9 to insert a field, then write between the brackets. The {IF} syntax is

{ IF condition "do when true" "do when false" }

You can have fields within the "do when true" and "do when false" and you need to enclose the whole "do when true/false" with double quotes. Within the "do when true/false" you can have paragraph marks, page breaks, etc.

I'll be happy to arrange the fields in your document, if you send me the merge document with the field names in place. You can replace the text with dummy text. I really only need the part with the CC block.

cheers, teylyn

Featured Post

A Knowledge Base That Stays Up-to-Date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now