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

Free Support Forum - aspose.com

Multiple Brackets in an IF statement prevent successful Merge


I have a datasource with a column in it that has the following value: 1) 2)

When this datasource is processed using the command: docTemplate.MailMerge.Execute(dtCopyOfDataSource); an invalid cast exception is raised and the merge fails.

The merge template contains the line: { IF { MERGEFIELD M_1_Comments }="" "Blank" "{ MERGEFIELD M_1_Comments }" }

I have attached a sample report and datasource. This appears to work in word directly, but not through the C# code i’m using.

I’m using version 15.11 currently. My subscription has expired so cannot try a later version. If it has been addressed already, i’d appreciate a reference to the solution so i can justify the renewal costs.

Martyn17573Test.zip (9.8 KB)


Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for .NET 17.10 with following code example and have not found the shared issue. Please use Aspose.Words for .NET 17.10. We have attached the output DOCX with this post for your kind reference. 17.10.zip (8.4 KB)

Document document = new Document(MyDir + "17573Test.docx");
document.MailMerge.Execute(new String[] { "M_1_Comments" }, new String[] { "1) 2)" });
document.WarningCallback = new HandleDocumentWarnings();
document.Save(MyDir + "17.10.docx");

Thanks for the reply. I have tried your code sample with my version of Aspose and the problem still exists - I can therefore only assume it has been addressed somewhere between 15.11 and 17.10 and isn’t caused by the way it is implemented in my code.

Thanks for your assistance.


Please upgrade to the latest version of Aspose.Words for .NET 17.10 to get the desired output. Please let us know if you have any more queries.