Free Support Forum - aspose.com

Removing blank fields / lines in mailmerge

Hi,

In word you can select remove blank lines whilst mailmerging a document, can you do this via aspose.word, if so how.

This to stop the following happening where some address fields in the database are empty strings for some records but not others:

Mr D Smith

18 West Street

Barnsley

As you can see the result would not look very professional in a letter, although you could go through and remove the blank mailmerge lines manually for 1 or 2. It would not be so easy for say 70 document or more.

Thanks

You can set Document.MailMerge.RemoveEmptyParagraphs to true to specify that the paragraphs that contained mail merge fields with no data should be removed from the document.

And you can call Document.MailMerge.DeleteFields to remove merge related fields from the document that were not used during mail merge.

Hope this helps,

Thanks for the speedy response, works just the way I wanted it.