Free Support Forum - aspose.com

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.


#9

Hi Tahir,

unfortunately we have found another corner case, where this isn’t working as expected. Please find attached solution MailMergeIfUnresolved.zip (4.4 MB). The IF field seems to be resolved correctly and it pulls the data from secondary data set, however the mergefields codes are also visible as text in output documents. Could you please take a look and let me know if there is some config option we can use to get desired output?

Thanks,
Mateusz


#10

@acturisaspose

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-17944. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


#11

Hi Tahir,

many thanks for looking into this. Could you please let me know if there is any workaround for this issue? Unfortunately we have spotted this in quite a few of our clients templates.

Thanks,
Mateusz


#12

@acturisaspose

Thanks for your inquiry. Unfortunately, there is no workaround for this issue. The MailMerge.ExecuteWithRegions causes this issue. We will inform you via this forum thread once there is an update available on this issue. We apologize for your inconvenience.


#13

The issues you have found earlier (filed as WORDSNET-17944) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan