Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Mail Merge problem 1

Status
Not open for further replies.

joemajestee

Programmer
May 5, 2010
35
US
I am trying to get a mailmerge to work. When I step through the records, the document looks fine, however I encounter an error when I execute the merge to a new document. The error that displays is "A field calculation error occured in record #" for each record. Then in the resulting document, on only the first "property", "Error! Unknown opcode for conditional" shows up instead of the data. When I go back to the original doc, that text then displays in the same place as I step through the records again.

The data source is an excel worksheet. The if statements, the first of which seems to be causing the error are meant to display property information only if the corresponding cell in Excel is not blank. I deleted the first statement and got similar errors eventually. Pasted below is the word code. CRLF is a carriage return.

{ MERGEFIELD "OrgPerson_SortName" } - Total of Units is {MERGEFIELD "Total_Units"}

Property List with Unit Count:{ IF{ MERGEFIELD "Prop1" }"CRLF{ MERGEFIELD "Prop1"}, { MERGEFIELD "Unit1" } Units"}{ IF{ MERGEFIELD "Prop2" }"CRLF{ MERGEFIELD "Prop2"}, { MERGEFIELD "Unit2" } Units"}{ IF{ MERGEFIELD "Prop3" }"CRLF{ MERGEFIELD "Prop3"}, { MERGEFIELD "Unit3" } Units"}

and so on. The error appears immediately after Property List with Unit Count:

Thanks for your help.

 
Hi Joe,

Your IF staments are malformed, since they lack the condition being tested. For example, to test for an empty text field, the statement coded as:
{IF{MERGEFIELD "Prop1"}"CRLF{MERGEFIELD "Prop1"}, {MERGEFIELD "Unit1"} Units"}
should be:
{IF{MERGEFIELD "Prop1"}<> "" "CRLF{MERGEFIELD "Prop1"}, {MERGEFIELD "Unit1"} Units"}


Cheers
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top