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

Free Support Forum - aspose.com

RemoveUnusedRegions cleanup option with multiple tables

I have multiple datatables returned as part of a dataset, which is the input for my Aspose word merge.

Depending on the records I pull, some of the tables might return 0 records.

The way, my code is structured is to fist populate document data using doc.MailMerge.Execute method to populate regular (non-region) data.

I then loop through each data table and populate regions using doc.MailMerge.ExecuteWithRegions method.

I am using RemoveUnusedRegions cleanup option to remove empty regions.

However, once I hit a table with 0 records and the cleanup option is set, none of the subsequent regions (TableStart — TableEnd) get populated even if they have records present.

Please hep


HI Nandu,

I think, you should specify MailMergeCleanupOptions just before executing the last doc.MailMerge.ExecuteWithRegions method at the end of your code. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document DOCX
  • Please create a standalone console application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.

Best regards,

Hi Awais

Thank you for getting back to me with the suggestion.
The trick you suggested seems to have solved my issue. I am testing various combinations and will let you know if I get into further issues.

Do you still want me to send you the code?

Thanks again

Hi Nandu,

If moving MailMergeCleanupOptions at the last just before the last time when you call ExecuteWithRegions method resolves this problem, then we won’t be needing your code for testing. Please let us know if you have any troubles and we will be glad to look into this further for you.

Best regards,