?
Solved

Insert Conditional Paragraph in Word Merge Template

Posted on 2011-02-17
1
Medium Priority
?
1,348 Views
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.
0
Comment
Question by:SueJStevens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst (Microsoft MVP / EE MVE) earned 2000 total points
ID: 34920345
Hello,

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
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Suggested Courses

777 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