Aspose.Words doesnt update all mergefields in Word IF constructions

We are upgrading Aspose Words from version 15.7.0.0 to 19.12.
Also used latest Aspose Words version 23.8 which has the same issue as 19.12.

The issue arrises when having a Word document which contains an IF statement in which the result for either TRUE or FALSE uses the same MERGEFIELD but each with different formatting (e.g. MERGEFIELD field1 and MERGEFIELD field1 * FirsCap.
In that case only one MERGEFIELD will actually be replaced by a value when in Code doc.MailMerge.Execute(keys, vals) is done

In version 15.7 this worked without any problem.

Attatched a ZIP with a small sample Word document and a VB.NET solution performing the mailmerge.

Hopefully someone has a solution for this since it now seems we have to manually scan all our templates (many hundreds with many more blocks) to find and workout this issue.

AsposeIssue.zip (36.1 KB)

@adoelen You should enable MailMerge.UnconditionalMergeFieldsAndRegions option to get the desired output:

Document doc = new Document(@"C:\Temp\in.docx");
doc.MailMerge.UnconditionalMergeFieldsAndRegions = true;
doc.MailMerge.Execute(new string[] { "ageabove18", "title_plus_surname" }, new string[] { "true", "dhr Erwin" });
doc.Save(@"C:\Temp\out.docx");

@alexey.noskov , thanks for the quick help! This seems indeed to be the solution!

Many many thanks

1 Like