We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Mail Merge field values not retaining changed value in print preview

We have an Template which contains 3 merge fields following the Date merge field, after the merge phase we allow users to manually add text to the document. We are able to get the document to merge successfully, but when the user amends the text in all 3 fields in the merged document via Word, and views them in the Print Preview, all the changes are lost except the last one. The last mergefield present in the document retains its changed value, while all other merge fields loses their changes.

If we remove the Date from the field from the template and repeat the test we are able to see all the changes via the Print Preview.

We are using Aspose 13.8 version.

We have included two Word Templates as the one issued by our client(With out Quotes.doc)had a syntax error with the Date field – however when we addressed this in template(With Quotes.doc) – the problem persisted.

Code to replicate this problem is as follows. Attached is the template and merged document.

using (DataTable mergeData = new DataTable())

{

mergeData.Columns.Add("CUST_COUNTY");

mergeData.Columns.Add("CUST_TOWN");

mergeData.Columns.Add("USR_REF");

mergeData.Rows.Add("Leeds", "Cardiff", "YORKSHIRE");

Document doc = new Document("TESTA.doc");

doc.MailMerge.Execute(mergeData);

doc.Save("Merged Document.doc", SaveFormat.Doc);

}

Hi,


Thanks for your inquiry. The problem occurs because of IF fields. The merge fields in your documents are contained inside IF fields, and the mail merged documents display FALSE part of the IF fields. In this case, you need to change content of FALSE part. You can see FALSE part by pressing ALT+F9 keys. Alternatively, you can use the following code to generate the mail merged document without IF fields.

Document doc = new Document(MyDir + @“With+out+Quotes.doc”);

using (DataTable mergeData = new DataTable())

{

mergeData.Columns.Add("CUST_COUNTY");

mergeData.Columns.Add("CUST_TOWN");

mergeData.Columns.Add("USR_REF");

mergeData.Rows.Add("Leeds", "Cardiff", "YORKSHIRE");

doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveContainingFields;

doc.MailMerge.Execute(mergeData);

doc.Save(MyDir + @"out-With+out+Quotes.doc");

}


I hope, this helps.

Best regards,

Hi Thanks for quick response.

The 3 merge fields which are inside IF fields works perfectly when there is no Date merge field in the template. We are able to see the changed values via print preview.

The problem is occurring only when there is Date merge field in the template.

Note:All the three merge fields in IF statement are contained inside IF fields and has FALSE part.

The question here is it is not working for first,second IF statements and Third IF statement is working fine when there is Date merge field in the template. We are able to see the changed values via print preview only for the third IF statement.

If we remove the Date merge field all IF statements works fine. we able to see the changed values via print preview for all the three IF statements.

Hope this Helps.

Thanks,

Vinay

Hi Vinay,


Thanks for the additional information. I have generated couple of output documents here for your reference. These documents behave the same when using Microsoft Word 2013. However, for the sake of any correction, I have logged this problem in our issue tracking system as WORDSNET-10104. Our development team will further look into the details of this problem and we will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

Hi Vinay,


Thanks for being patient. Unfortunately, the implementation of the fix to this issue has been postponed till a later date and we cannot push it into production right now because we need to investigate the best possible way to fix this. It seems more like a bug in MS Word. Rest assured, we will inform you via this thread as soon as WORDSNET-10104 is resolved. We apologize for your inconvenience.

Best regards,

@sb_vinay,

Regarding WORDSNET-10104, our product team has completed the work on your issue and has come to a conclusion that they would not be able to implement the fix to your issue. Your issue (WORDSNET-10104) has now been closed with ‘Won’t Fix’ resolution. Both files (with and without field “DATE”) are syntactically correct. But with the first file (with date field) we can reproduce this bug and without “DATE” field we cannot. We believe this is MS Word bug and it cannot be reproduced in OpenOffice.

out-With out Quotes.zip (2.2 KB)
out-With Quotes.zip (2.3 KB)
With out Quotes.zip (2.3 KB)
With Quotes.zip (5.7 KB)

Best regards,
Awais Hafeez