Please Note: This article is written for users of the following Microsoft Word versions: 2007 and 2010. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Conditionally Adding a Period in a Mail Merge.

Conditionally Adding a Period in a Mail Merge

by Allen Wyatt
(last updated September 29, 2014)

2

Rose uses Word's mail-merge feature to create certificates. The source data is in an Access database, and sometimes the middle initial pulled from the database has a period after the initial and sometimes it doesn't. Rose is wondering if there is a way, in Word, to have the mail merge check for the trailing period on the data in the middle initial field and automatically add one if necessary.

Unfortunately, we couldn't come up with a way to do this. Word doesn't seem to have the capability to check for characters within the merged data on the fly. We did come up with a workaround, however. Open your merge document and, right after the merge field that inserts the middle initial, type a period. When you do your merge, some middle initials will have one period (if they had none in the data source) and others will have two (if they had one in the data source). All you then need to do is a Find and Replace operation, replacing all instances of two periods with a single period.

This may not be as "clean" as you desire; after all, it adds an extra step to your certificate preparation. It is easier, however, than manually going through the merged file and looking at each middle initial yourself.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (9629) applies to Microsoft Word 2007 and 2010. You can find a version of this tip for the older menu interface of Word here: Conditionally Adding a Period in a Mail Merge.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Quickly Dumping Array Contents

A VBA macro that will erase all of the information in your array.

Discover More

Searching Through Many Workbooks

If you have a folder that contains dozens or hundreds of workbooks, you may need to search through those workbooks to find ...

Discover More

Sequentially Numbered Labels

A common task in Word is to create labels. This tip presents two approaches you can use when you need to create labels that ...

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (ribbon)

Selecting Different Trays in a Mail Merge

When you create a mail-merged document, you might want some pages of the document printed on paper from one printer tray and ...

Discover More

Checking Your Data File

When you get ready to merge a document with a data source, you'll want to make sure that everything is "as expected" before ...

Discover More

Using Mail Merge to Complete Documents

Mail merge can be used to put together groups of documents that rely on common information. This tip shows how mail merge ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 5 + 0?

2015-03-11 13:36:57

scott saltz

an easier way:

{ MERGEFIELD "MidInt" }


2013-07-30 08:00:12

Bryan

You can do this with field codes pretty easily. Assuming your middle initial field is called "MidInt", here's what you would use:

{ MERGEFIELD MidInt }{ IF { COMPARE { MERGEFIELD MidInt } = "*." } = 1 "" "." }

Remember you can't manually add the brackets; you have to use CTRL+F9. Use ALT+F9 to toggle field code view, and F9 to update a field code (or right click, then select Update Field).

Here's what it's doing:
* { MERGEFIELD MidInt } -- This simply adds the middle initial, with or without the trailing period
* { COMPARE { MERGEFIELD MidInt } = "*." } -- the COMPARE field compares two strings. We are comparing the MidInt field against "*.". Since * is a wildcard, we are looking for anything that ends in a period. The COMPARE field returns 1 for true and 0 for false.
* IF [compare clause] = 1 "" "." } -- the IF field has the syntax: { IF [comparison] [true result] [false result] }. In this case, since the compare clause above returns 1 when there is a period, we want [true result] to be an empty string, and [false result] to be a period: if there's already a period there, don't add one, otherwise add one.

Note that, as usual, this is another area where you should question the data instead of trying to work around it. Why is that field inconsistent in the first place? A well designed database shouldn't have this issue. Luckily, if you are working with Access or any other database program, you can rather easily correct the data. If you want to remove the period from every middle initial field (my recommendation) you can use the following SQL (assuming that MidInt is found on the Names table):

UPDATE Names
SET MidInt = LEFT(MidInt, LEN(MidInt) - 1)
WHERE RIGHT(MidInt, 1) = “.”

Or if you want to add a period to every initial:
UPDATE Names
SET MidInt = MidInt & “.”
WHERE RIGHT(MidInt, 1) <> “.”


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.