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

Free Support Forum - aspose.com

Mail Merge - Can you add a 'Mail Merge' Field

This might seem a little weird but I need to add a mail merge field to the newly created document. I am trying to create a mail merge document that will act as a template that our clients can use to run reports. So this template needs to have the <<TableStart: xxx>> mail merge field in there.

Any possible solutions for this? Can Aspose write MS Word MailMerge Fields into a document?

Thanks

–John

Hi John,


Thanks for your inquiry. Sure, you can use the following code to insert a mail merge field in document:
Document doc = new Document(getMyDir() + “in.docx”);
DocumentBuilder builder = new DocumentBuilder(doc);

builder.moveToDocumentEnd();

builder.insertField(“MERGEFIELD TableStart:xxx”, “”);

doc.save(getMyDir() + “out.docx”);

I hope, this helps.

Best regards,