WD: Incorrect Results Using Backslash in Conditional Merge

Last reviewed: February 18, 1998
Article ID: Q176620
The information in this article applies to:
  • Microsoft Word 97 for Windows
  • Microsoft Word 98 Macintosh Edition

SYMPTOMS

When you use a conditional MergeField for a result that includes quotation marks, the result of the field will contain a backslash.

For example, if you have the following conditional statement in your mail merge main document which uses backslashes to have quotation marks appear in the result of a true condition for a record

   {IF {MERGEFIELD name} = "John Doe" "\"Now is the time...\"" "false
   condition"}

you would expect to receive the result of "Now is the time" on a true statement. However, Word will give you the following result:

   "Now is the time...\"

NOTE: This problem may also occur with commas or backslashes.

WORKAROUND

To work around this problem, use a unique character in place of the quotation mark. After the merge is completed, use the Replace command to search for the unique character and replace it with a quotation mark. (Note that the character you choose should not occur elsewhere in your document.)

Example

In the merge field, use the pound sign instead of quotation marks.

   {IF {MERGEFIELD name} = "John Doe" "#Now is the time...#" "false
   condition"}

After the merge is completed, follow these steps to replace the pound sign with a quotation mark:

  1. On the Edit menu, click Replace.

  2. In the Find What box, type the unique character (the pound sign in this example).

  3. In the Replace With box, type a quotation mark.

All instances of the unique character (the pound sign in this example) will be replaced with a quotation mark.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The general syntax for a conditional {IF} field is as follows:

   {IF {MERGEFIELD name} = "John Doe" "true condition" "false condition"}

Note that quotation marks are used to denote the parameters of the conditional statements, and are not included in the printed result of the merge.

The comma also has a special use inside the {IF} field. Therefore, use the backslash before a comma as well as before the quotation mark. In addition, the backslash has a special use inside the {IF} field. Therefore, use a backslash before a backslash. In other words, use two backslashes if you want one to appear in the merged document.

For example to have the result "John said, "The file was on f:\harddrive\ my documents"", the {IF} field should have a format of:

   {IF {MERGEFIELD name} = "John Doe" "John said, \"The file was on
   f:\\harddrive\\my documents\"" "false condition"}

Note that the actual result of this field will be

   John Doe said, \"The file was on f:\\harddrive\\my documents\"

For additional information about this issue, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q134998
   TITLE     : WD: Certain Characters Do Not Appear in Field Result

For additional information about this situation in earlier versions of Word, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q:146648
   TITLE     : WD: How to Use Quotation Marks in a Conditional Merge Result


Additional query words: quote mail merge else print condition word8 word97

Keywords : kbfield kbmerge macword98
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 18, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.