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

Free Support Forum - aspose.com

How to use the CollectErrors fonctionnality?

I’m using Aspose Word .Net 17.8 and I get the following problem :

I have a field that is not define as a mergefield in my document and the mail merge fail with an error InvalidOperationException: Invalid document model (full call stack bellow).

The merge field as been define inside acolade and if with a field code and acolade only { FESP } without specifying “MERGEFIELD”.

{{ FESP }}

or { "Text … " { FESP } }

I’m wondering if it’s possible to get a specific error about what field it’s causing the probleme instead of a generic invalid document model error. Can I validate the document/fields in someway?
The code to do the mail merge is :

        Dim doc As Document = documentTemplate.Clone()
        Dim dataTable As DataTable = dataSet.Tables.Item(0)
        Dim outStream = New MemoryStream()
        doc.Save(outStream, SaveFormat.Pdf)
        Dim data As Byte() = outStream.ToArray()

System.InvalidOperationException: Invalid document model. Operation can not be completed.
at .( , FieldChar , Boolean )
at .(FieldChar )
at .(FieldChar )
at ​ .()
at ​ .()
at ​ . ​ ()
at .(Boolean , Boolean )
at .( )
at . ​ ()
at .()
at . ​ ()
at .(Field )
at .(Field )
at . ( )
at .( )
at .( )
at .( )
at .( , )
at .(ArrayList )
at ​ .(ArrayList , )
at ​ . ()
at Aspose.Words.MailMerging.MailMerge.( )
at Aspose.Words.MailMerging.MailMerge.Execute(IMailMergeDataSource dataSource)


To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your simplified input Word document
  • Please also create a simplified standalone console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size.

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.


I have found 2 possibles solutions that I will use for now.

First I fix the field for {{ MERGEFIELD FESP }} and it’s temporary fix my problem.

Eventually I will update to the last version of aspose word. I have use the trial and I don’t have the same problem.


It is great that you will be able to resolve this issue on your end. Please let us know any time you have any further queries.