WD: Calculations with Print Merge Causes Errors (98836)



The information in this article applies to:

  • Microsoft Word for Windows 2.0
  • Microsoft Word for Windows 2.0a
  • Microsoft Word for Windows 2.0b
  • Microsoft Word for Windows 2.0c
  • Microsoft Word for Windows 6.0
  • Microsoft Word for Windows 6.0a
  • Microsoft Word for Windows 6.0c
  • Microsoft Word for Windows 95
  • Microsoft Word for Windows 95 7.0a
  • Microsoft Word 97 for Windows
  • Microsoft Word for the Macintosh 6.0
  • Microsoft Word for the Macintosh 6.0.1
  • Microsoft Word for the Macintosh 6.0.1a

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} <> "" {MERGEFIELD num1} 0} +
          {if {MERGEFIELD num2} <> "" {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 "User's Guide."

REFERENCES

"User's Guide," version 2.0, pages 639-645

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:kbmerge kbprint kbualink97 KB98836