Free Support Forum -

Preserving MERGEFIELD identifier

Mailmerge works great for creating a new document but the MERGEFIELD field tags are lost in the new Word document. How can we preserve the MERGEFIELD fields so we can keep updating the document with revised metadata?


Thanks for your inquiry. Merge fields in your template will be replaced with values from your data source. If you want to update the generated document then you should generate new document using your template file. For example see the following code.

This code will generate the report.

Document doc = new Document(@"in.doc"); //Open the template document

string[] names = {"FieldName" };

string[] values = { "FirstUpdate" };

doc.MailMerge.Execute(names, values);

doc.Save(@"out.doc"); //save the report

You can run this code again using another data and get new report.

I hope that this will help you.

Best regards.