MailMergeCleanupOptions to remove Merge fields only


#1

Hi Aspose team,

I’d just like to confirm if there is no option to only remove unused MERGEFIELDS from document after performing MailMerge? We encountered a case where REF field in our template is removed from document after mail merge.

Correct me if I’m wrong, but the alternative here would be to not adding MailMergeCleanupOptions.RemoveUnusedFields flag and write custom methods that removes fields of specyfic type after merge? Could you please advice if this will affect IF statements as well?

Thanks,
Mateusz

P.S. - just a small suggestion - when writing questions there is a suggestions window, but to some of the topics displayed there I’m having no access: https://forum.aspose.com/t/exception-amp-quot-year-month-and-day-parameters-describe-an-un-representable-datetime-amp-quot-opening-file-with-aspose-cells/134194 - maybe something worth checking :slight_smile:


#2

@acturisaspose

Thanks for your inquiry. You can use MailMerge.DeleteFields method to remove mail merge related fields from the document after performing mail merge operation. Hope this helps you.

If you still face problem, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

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

PS: To attach these resources, please zip and upload them.


#3

Hi Tahir,

many thanks for your response, however there is a problem with this fix. Please find the example attached.asposeRefAndIf.zip (4.5 MB)

MailMergeCleanupOptions.RemoveUnusedRegions option when turned on causes RefField to be removed from the output, turned off causes the mergefield with TableStart appear in the output document. Could you please help me find the solution that would work in both cases (so the REF field is not removed, and we get rid of the mergefield text from the output at the same time)?

Many thanks for your support so far,
Mateusz


#4

@acturisaspose

Thanks for sharing the detail. We have tested the scenario using the latest version of Aspose.Words for .NET 18.12 and have noticed that the RefField is not removed from the document in both cases.

Could you please share the screenshots of problematic section of output document along with expected output Word document? We will then provide you more information about your query.


#5

Hi Tahir,

many thanks for looking into this. I’m currently using 18.6, I’ll retest the problematic document using the newest version and let you know if I can still replicate the issue.

Thanks,
Mateusz


#6

@acturisaspose

Please try Aspose.Words for .NET 18.12 and let us know if you have any more queries.


#7

Hi Tahir,

sorry for the late response. We have retested and it’s working fine on 18.12. Many thanks for your help.

Thanks,
Mateusz


#8

@acturisaspose

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.