You are here:

Microsoft Word/Mail Merge Codes - Need Help


QUESTION: I really need some help with my merge codes (sample below). I am merging my word letter with an Excel worksheet.  (Using Microsoft Word & Excel 2010)I tried sending you this yesterday by uploading an image but you could not see the image. I hope you can help me.

Scenario: If the Appt_Date and Appt_Time are not blank, I want to display its contents.
But if Appt_Date and Appt_Time are blank, I want to display either the contents of the Mail_In or contents of the Call In column.(which ever column not blank)

These are the field codes I am using in my document in this order; but something is missing or out of place because this is not working.

{  IF  MERGEFIELD Appt_Date} = "" "" "Appointment Date: " }{  MERGEFIELD Appt_Date  } }
{  IF  MERGEFIELD Appt_Time } = "" "" "Appointment Time: }{  MERGEFIELD Appt_Time \@"h:mm AM/PM" } }
{  IF  MERGEFIELD Mail_In } = "" "" { MERGEFIELD Mail_In   } }

{  IF MERGEFIELD Call_In } = "" ""  { MERGEFIELD Call_In   } }

Microsoft Word LETTER

Interviewer: Jack Jones
Appointment Date: “Appt_Date”
Appointment Time: “Appt_Time”

January 18, 2015

Client Name
Client Address
City, State, Zip

I am using this DATA from my Excel worksheet:

Appt_Date          Appt_Time  Mail_In   Call_In
         Call for Appt
Tuesday, January 15, 2015  10:00 AM        
Tuesday, January 20, 2015  9:00 AM        
         Mail In    
         Call for Appt
         Mail In    
         Call for Appt
         Mail In    
         Mail In    
         Call for Appt

ANSWER: You need this syntax:

{ IF { MERGEFIELD Appt_Date } = "" "" "Appointment Date: { MERGEFIELD Appt_Date }
" }{ IF { MERGEFIELD Appt_Time } = "" "" "Appointment Time: { MERGEFIELD Appt_Time }
" }{ IF { MERGEFIELD Mail_In } = "" "" "{ MERGEFIELD Mail_In }
" }{ IF { MERGEFIELD Call_In } = "" "" "{ MERGEFIELD Call_In }
" }

Note that all pairs of braces must be inserted using Ctrl+F9, and you must put the line breaks or paragraph breaks inside the FalseText so that you won't have blank lines if the fields are blank.

---------- FOLLOW-UP ----------

QUESTION: Suzanne, thank you for helping me with this. Now I am going to ask a dumb question, what is the "False Text"? I don't know where to insert paragraph breaks or line breaks. Do you mean in between the "" "" " Quotation marks?

The syntax of an IF field is { IF Expression1 Operator Expression2 TrueText FalseText }. The TrueText is the expression between the first pair of quotation marks, the text that you want entered if the condition is true. The FalseText is the text between the second set of quotation marks. If you turn your condition around so that these are switched (that is, if you use the condition IF { MERGEFIELD x } <> ""), so that the FalseText would be the blank, then you can omit the FalseText entirely.

However you do it, though, if you don't want a blank line when the field is empty, you must make the line/paragraph break part of the text that is entered when there is data to be entered; that means that you must press Enter or Shift+Enter before the closing quotation marks of the FalseText (in this example) or TrueText (if you turn the condition around). This puts the closing quotation mark and field brace on the next line when viewed as in the example above but will give you the result you want when you perform the merge.
About Microsoft Word
This topic answers questions related to Microsoft Word stand-alone or Microsoft Office Word including Word 2003, Word 2007, Office 2000, and Office XP. You can get Word help on formatting text, tables, tabs, fonts, styles, general Word layouts, bullets, headings, and outlines, using templates, toolbar modifications, and using Track Changes. You may also find tips on linking Word and Excel embedded objects including charts. This site does not provide a general Word tutorial nor the basics of using a word processor. It provides specific answers to using Microsoft Word only. If you do not see your Word question answered in this area then please ask a Word question here

Microsoft Word

All Answers

Answers by Expert:

Ask Experts


Suzanne S. Barnhill


I've been using Word for Windows since version 2.0 (1992), and the more I learn about it, the more I realize how little I know. But I may know a few things that you don't, and I'll help if I can. I answer many questions every day in Microsoft's peer support forums and as a result have been awarded the MVP (Most Valuable Professional) designation by Microsoft Corporation. You may be able to find the answer to your question at the Word MVPs' FAQ site or at my own Word FAQ site, so please check those first! Please, no questions about VBA (macros), Registry editing, networks, or complex merges, as I have no experience with these aspects of Word, nor do I have any experience with Word for Mac. Please indicate which version of Word you are using; if you are not sure, see "What version of Word do I have?".


I have a master's degree in classics (Latin), which is surprisingly helpful, though I no longer teach. The things I am proudest of: Having raised two children to maturity, both Merit Scholars, both college graduates (one a philosophy major!), one Phi Beta Kappa (from Harvard!); having been made a Paul Harris Fellow by my Rotary club; having been designated a Microsoft MVP.

Rotary Club of Fairhope, Friends of the Fairhope Public Library

B.A. (Latin), Agnes Scott College, 1966; M.A. (Classics), Emory University, 1972.

Awards and Honors
Microsoft Most Valuable Professional award every year since 1999; many Rotary honors

©2017 All rights reserved.