Free Support Forum - aspose.com

Merge Field Cleanup when document opens

I have a word document that loops through several queries to determine what is merged into the document. I'm checking each query to assure that a blank dataset isn't returned so that I don't end up with a blank page. Is there anyway to eliminate the word merge fields when the document opens so that they users don't see them? I thought I had read somewhere that the cleanup was done automatically, but when my document is opened all the merge fields that were not processed due to no data returned are left there. This mostly applies to merging of region information, where data is added to a table if it exists.

Thanks

Donna

Hi

Thanks for your inquiry. I think that you can try using MailMerge.DeleteFields() method.

doc.MailMerge.DeleteFields();

I hope this could help you.

Best regards.