• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3038
  • Last Modified:

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?
0
thechrisrobertstoo
Asked:
thechrisrobertstoo
  • 3
  • 2
1 Solution
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now