Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using empty Columns when Merging excel to word

Status
Not open for further replies.

coreysan

Programmer
Jul 24, 2006
7
US
I'm merging an excel file of addresses into word, and sometimes the 2nd address line will be empty or null. I would like the merge to leave the line there instead of
shifting up the data. Can that be done?

So, instead of:

(excel) (result)

<<name>> Mr. NoName
<<address1>> 123 Anywhere St.
<<address2>> Anywhere, AZ 11111
<<city>><<ST>><<ZIP>>


It would be:

Mr. NoName
123 Anywhere St.

Anywhere, AZ 11111

Can that be done?
 
Hi,

If you are using Office 97.
You need to select Tools, Mail Merge, Merge. Make sure you select Print Blank Lines when data fields are empty.

HTH.

Peter.

Remember- It's nice to be important,
but it's important to be nice :)
 
Hi coreysan,

Here's how you can suppress lines inserted by empty mergefields in Word-
. duplicate the mailmerge field to be suppressed (eg «MyData») so that you get:
«MyData»«MyData»;
. select both fields and Press Ctrl-F9, you'll get:
{ «MyData»«MyData» };
. fill in between the braces so that you end up with:
{IF«myData»= "" "" "«MyData»¶
"},
where the '¶' is a paragraph mark or line-feed, depending on which you're using
. delete the existing paragraph mark or line-feed that's outside the mergefield;
. position the cursor anywhere in this field and press F9 to update it;
. run your mailmerge.


Cheers

[MS MVP - Word]
 
Thanks for the explanation. When I open MS Word 2003, I insert the merge fields on the page, and simply click create new document. Isn't there an easy way to tell the inserted field that if the datasource column is empty, print a blank line in that spot?

Are you saying I need to write a macro and make changes as you wrote?
 
Hi coreysan,

The solution I posted was for suppressing blank lines when there are no data.

If you want a line-feed after the mergefield, regardless of whether the field has anything in it, you need to either:
. use the 'Print Blank Lines' option that Peter suggested - it's an option attached to the 'merge' button; or
. explicity insert the line feeds after the relevant mergefields.

There is no need for macros/vba in any of this.

Cheers

[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top