Microsoft KB Archive/98836

= WD: Calculations with Print Merge Causes Errors =

Article ID: 98836

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Word 2.0 Standard Edition
 * Microsoft Word 2.0a
 * Microsoft Office Word 2003
 * Microsoft Word 2.0c
 * Microsoft Word 6.0 Standard Edition
 * Microsoft Word 6.0a
 * Microsoft Word 6.0c
 * Microsoft Word 95 Standard Edition
 * Microsoft Word 95a
 * Microsoft Word 97 Standard Edition
 * Microsoft Word 6.0 for Macintosh
 * Microsoft Word 6.01 for Macintosh
 * Microsoft Word 6.01 for Macintosh

-



This article was previously published under Q98836



In Word, you can include numeric values in a print merge data file to use in calculations in the main document. If any of the fields in the data file are blank, however, one of two error messages may appear in the merged document:

!Unexpected End of Expression

-or-

!Syntax Error



WORKAROUND
 Make sure that all the fields used for calculations contain data.

Type 0 (zero) in any blank field.

The drawback to this workaround is that it could become tedious to maintain for large data files.

-or-  In the calculation field in your main document, insert an IF statement that tests whether the field is blank. The following IF statement uses the value from the data file when the field is not blank; otherwise it uses 0 for the calculation: {= {if {MERGEFIELD num1} <> &quot;&quot; {MERGEFIELD num1} 0} + {if {MERGEFIELD num2} <> &quot;&quot; {MERGEFIELD num2} 0}} Note: To create the curly field brackets, press CTRL+F9 (Windows) or COMMAND+F9 (Macintosh). 

For more information on using IF statement in a print merge, consult pages 639-645 in the Word for Windows &quot;User's Guide.&quot;

