PDA

View Full Version : Field Calculation Error in Mail Merge Document



fionabolt
03-11-2010, 05:01 AM
I have a whole load of templates that obtain all of their field values via a database.

Everything worked fine until I added the following to the field in the footer:

{IF”{ STYLEREF “Doc title (Agency)”}” <>”Error*””{ STYLEREF “Doc title (Agency)”}”}

Now, if the template does not contain a paragraph with the style "Doc title (Agency)", then, on performing the mail merge, I get the error “A field calculation error occurred in record 1”

Any ideas why this field reference should cause a problem with mailmerge?
I found this link in MS http://support.microsoft.com/default.aspx?scid=kb;en-us;Q120278, however it (a) relates to Word 95 and 6 - I am using 2003 (11), and (b) the solution is to "refer to two files" . I assume they mean have two OpenDataSource files, but I cannot fathom out a method to have two OpenDataSource files.
Your help would be much appreciated.
Regards,

macropod
03-11-2010, 01:27 PM
Hi Fiona,

Try changing the field code to:
{IF{STYLEREF "Doc title (Agency)"}<> "Error*" {STYLEREF "Doc title (Agency)"}}
paying careful attention to the spacing between the expressions.

fionabolt
03-12-2010, 01:36 AM
Macropod

Thank you very much. I've tried every different kind of spacing (frustrating that Word's insert field doesn't do this correctly for you) However, that spacing still does not fix the error. Here is a screen shot of the spacing I've copied from your post:

http://www.vbaexpress.com/forum/C:\Documents and Settings\lewisf\Desktop\img.bmp

Any other solutions?

Regards,
Fiona

macropod
03-12-2010, 03:00 PM
Hi Fiona,

OK, lets go back to the basics. If I understand what you're trying to do, it's to use an IF test to test for either:
1. the presence of a Style named "Doc title (Agency)" and, if it's absent, suppress the STYLEREF error message; or
2. a string beginning with 'Error' in the Style named "Doc title (Agency)" and, if it's absent, suppress the string.

The following comments address scenario 1.

In a mailmerge, you could only not have the Style named "Doc title (Agency)" exist but not be present in a particular record via the use of an IF test that controls whether something in that Style gets output. If that's what you're doing, I can understand the field calculation error. The simple solution for this is to have, say, an empty paragraph in that Style (or just a space character, if it's a character Style), located after the IF test in the body of the document. That way, the Style will always exist and you won't need the IF test for the STYLEREF field.

If you're not trying to control whether something in that Style gets output, then the error message produced by the STYLEREF field (not the field calc error) suggests you've mis-named the Style in the STYLEREF field.