WD98: How to Suppress Blank Spaces in a Mail Merge (179674)
The information in this article applies to:
- Microsoft Word 98 Macintosh Edition
This article was previously published under Q179674 SUMMARY
During a mail merge, you may want to eliminate blank spaces when there is
no information available for a merge field in a line of text. This articles
discuses why blank spaces occur, and it includes a method you can use to
eliminate these blank spaces.
MORE INFORMATIONWhy Do Blank Spaces Occur?
Blank spaces occur most often in a mail merge when you use a title,
honorific, or middle initial with a name. When these merge fields are used,
a space is required between them and the name they refer to. If there is no
data for that field, the extra space needs to be eliminated.
Using an IF Field to Remove an Unwanted Space Character
You can use an IF (conditional) field and make the space part of the
conditional field so that when the field in question is empty, the space is
not created.
NOTE: In general, when you view a mail merge main document, merge field
names appear in chevrons <<MERGE FIELD>>. To view the actual field codes
that are in the document, press and hold the OPTION key and then press the
F9 key to toggle the field codes off and on. Note also that the {} (curly
brackets) that define a field cannot be simply typed. To create a pair of
special brackets (create a field) press and hold the COMMAND key and then
press F9.
In the samples that follow <space> represents pressing the space bar once,
while <Return> represents pressing the RETURN key once.
In a main merge document a typical name line often resembles the following:
<<Title>><space><<FirstName>><space><<LastName>><Return>
To see the actual field codes press, OPTION+F9. The resulting text will
resemble the following:
{MERGEFIELD Title}<space>{MERGEFIELD FirstName}<space>
{MERGEFIELD LastName}<Return>
NOTE: Ignore the line wrapping on the screen for these examples. The line
in the merge will actually end at the <Return>.
The space after the Title merge field can be eliminated by placing the
merge field and the space in an IF conditional field. The resulting field
will look like this:
{IF {MERGEFIELD Title}<>"" "{MERGEFIELD Title}<space>"}
The logic of the IF field reads "If the Title field ({MERGEFIELD Title}) is
greater than or less than (<>) empty ("") (this is a programming way of
saying not empty) insert what is in the Title field plus a space
("{MERGEFIELD Title}<space>") otherwise do nothing."
To create the IF field for this example, follow these steps:
- Display the field codes by pressing OPTION+F9.
- Position the insertion point before the Title merge field.
- Press COMMAND+F9 to create a new field (field1). With the insertion
point inside field1, type
where space is the character you get when you press the SPACEBAR.
- Without moving the insertion point, create another new field inside
field1 by pressing COMMAND+F9 creating (field2). With the insertion
point in field2 type:
- Move the insertion point outside of field2 (one place to the right)
and while the insertion point is still inside field1, type
- Create another new field (field3) inside field1 by pressing COMMAND+F9.
- With the insertion point in field3, type:
- Move the insertion point outside of field3 (one place to the right)
and while still inside field1 type:
The conditional IF field is now complete. The name line should now
resemble the following:
{IF {MERGEFIELD Title}<>"" "{MERGEFIELD Title}<space>"}
{MERGEFIELD FirstName}<space>{MERGEFIELD LastName}<Return>
NOTE: Ignore the line wrapping displayed here. There should be no line
break between the end of the IF field and the start of the FirstName
merge field. This method will work with any merge field by simply
changing the name of the merge fields inside the IF field to correspond
with the appropriate merge field names in your data document.
- Delete the original Title merge field and the space behind it, and
Toggle the field codes off by pressing Option+F9.
NOTE: The IF field does not appear inside chevrons in this view as the
merge fields do. What will be seen at that location in the main document is
the result of the IF field for the current record. If that merge field is
empty in the current record there will be nothing in that location, if the
merge field contains text that text will be displayed at the If field
location.
REFERENCES
For information about this subject in other versions of Word, please see
the following articles in the Microsoft Knowledge Base:
72441 WD: Suppressing Blank Spaces in a Print Merge (Mail Merge)
Modification Type: | Major | Last Reviewed: | 10/4/2002 |
---|
Keywords: | kbhowto kbinfo kbmerge KB179674 |
---|
|