WD: Calculations with Print Merge Causes Errors

ID: Q98836


The information in this article applies to:
  • Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word 97 for Windows
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a

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

Additional query words: 6.0 2.0 winword word7 word6 7.0 word95 winword2 word97 6.01 6.01a macword

Keywords : kbprint kbualink97 kbmerge
Version : MACINTOSH:6.0,6.0.1,6.0.1a; WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a,97
Platform : MACINTOSH WINDOWS
Issue type :


Last Reviewed: October 29, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.