Word Mailmerge: How to only include carriage returns if a field returns text

I have a pretty standard mailmerge document that uses an excel file as a source document.  I know how to include text after a valid entry (like a space for example) by right mouse clicking on the field and choosing 'Edit Field', then ticking the 'Text to be inserted after' checkbox and then adding the text I want.

What I want with this current file is to add an extra carriage return or line break to separate field entries, but only when each field actually has data.

Can I do this?
thechrisrobertstooAsked:
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:
By default, if you put a carriage return immediately after the merge field, it will not appear in the output if the field is empty.
0
thechrisrobertstooAuthor Commented:
Ah, yes, you're right.  But I want to make the space an actual line break - but only when there is an entry.  I thought that I could just amend the paragraph formatting, but it then applies it even when there is no entry in the mailmerge field.

So, to clarify, I want to ensure a clear single line space between each mailmerge field, but only when they contain some actual text.
0
GrahamSkanRetiredCommented:
Sorry. Been out all day & evening.

in Word, if you press the {Enter} key, it creates a  paragraph mark. The following paragraph always starts on a new line, though spacing depends on the Paragraph properties which are derived, in the first instance, from the paragraph style.

It might help to show the formatting marks with the Show/Hide(¶) toggle on the Home tab. The pilcrow symbol (¶) is how the paragraph mark is represented when the formatting marks are showing.
0
thechrisrobertstooAuthor Commented:
Thanks for your comment.  I am aware of the paragraph marks and have changed the paragraph formatting to include a 12 point space after the paragraph, which, logically should mean that these spaces are only applied when data is present, as per your earlier point, but this isn't what is actually happening.  I get the spaces even when no information is showing.  I take your point that I ought to examine how many paragraph marks are showing on the output document.  It could be that some of the fields are outputting spaces or something as their contents.  I will check this out and let you know.
0
GrahamSkanRetiredCommented:
You could try using an IF field to test the value and act accordingly. For "if the merge field value is a zero length string, do nothing, otherwise output the value followed by a paragraph mark",  it would look like this:
{ IF { MERGEFIELD "MyMergeField"} = "" "" "{ MERGEFIELD "MyMergeField"} ¶
" }

However you can't use Word field functions to trim off or to test for trailing spaces. It this is likely to be a problem, it is best remedied in the datasource.
0

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
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 Word

From novice to tech pro — start learning today.