Free Support Forum - aspose.com

Mail merging and getting error: Specified argument was out of the range of valid values Parameter name: Number must be between 1 and 780 in this format

I am performing a mail merge (Aspose.Words v5.1.0.0) and receive the following error:

Source: Aspose.Words, Msg: Specified argument was out of the range of valid values.
Parameter name: Number must be between 1 and 780 in this format.
Stack: at x6c95d9cf46ff5f25.x00b47748a95c9437.x57fed9bbbd745fd0()
at x28925c9b27b37a46.x0fe76ecb9e9c47fd.x19fa8583862b446b(Int32 xbcea506a33cf9111, NumberStyle x3f5f7cef69e188c0, String x2eebe5b22e29f252)
at x28925c9b27b37a46.xcb0a3bdf6cb11198.x6f78ac76fd40fa4d(xd269993cc48a63d2 x01b557925841ae51, Int32 x66bbd7ed8c65740d)
at x28925c9b27b37a46.xcb0a3bdf6cb11198.xfb06d2c1aa126ed4(xd269993cc48a63d2 x01b557925841ae51)
at x28925c9b27b37a46.xcb0a3bdf6cb11198.xcbea96666365f182(Int32 x43eb71c4e55e38d0, Int32 xdcfcc0186c9811f1)
at x28925c9b27b37a46.xcb0a3bdf6cb11198.xcbea96666365f182(ParagraphFormat xefceefc9504671df)
at xe4ef70ab3eac1063.x9ce410fcf5282f93.x8324910d135bfe85()
at xe4ef70ab3eac1063.x9ce410fcf5282f93.x57a5d79d9b9d67f5(Paragraph x41baca1d6c0c2e8e)
at xe4ef70ab3eac1063.xa0851f56ffd58fbb.VisitParagraphStart(Paragraph para)
at Aspose.Words.Paragraph.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.x464d2134480a7bf2(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.Body.Accept(DocumentVisitor visitor)
at xe4ef70ab3eac1063.xa0851f56ffd58fbb.x51ee56decc29a9da(Section xb32f8dd719a105db)
at xe4ef70ab3eac1063.xa0851f56ffd58fbb.x8cac5adfe79bc025(x8556eed81191af11 x5ac1382edb7bf2c2)
at Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)

--------------------------
^^^ This is where the exception occured ^^^ (the output is from top to bottom)

Is there some sort of limit that is being exceeded?!?! I have a critical need to get thise resolved as soon as possible.

Thx!

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Could you please attach your template and provide me your code? I will try to reproduce this problem and provide you more information.

Best regards.

Ok, I have attached a sample app (with data and the template doc being used) that reproduces the problem. It is a VS2008 solution. It is a very simplistic app, just run it and press the merge button (I provided selections for data and template doc files...please just use the provided xml data file as this is what I was able to use to dup the problem consistently).

BTW, even though the sample saves the output to a file named "Test.doc", the output format I am having a problem with is the SaveFormat.AsposePDF.

Let me know if you have any questions.

Thx

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I managed to reproduce this problem. The error occurs during saving in AsposePdf format.

doc.Save ("Test.doc", SaveFormat.AsposePdf); //Error occurs here

I created new issue #5346 in our defect database. I will notify you as soon as it is fixed.

Best regards.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

As a workaround you can use the following code:

List lst = null;

List tmpList = null;

//Loop through all sections

foreach (Section sect in doc.Sections)

{

//Loop through all paragraphs in section

foreach (Paragraph par in sect.Body.Paragraphs)

{

//Search fro list items

if (par.ListFormat.List != null && lst == null)

{

lst = par.ListFormat.List;

//Copy list

tmpList = doc.Lists.AddCopy(lst);

}

if (lst == par.ListFormat.List && lst != null)

{

//Set new list

par.ListFormat.List = tmpList;

}

}

lst = null;

tmpList = null;

}

Insert this code directly before saving document.

Best regards.

OK, I will try it…will there still be a forth coming fix for this?

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Currently I can’t tell you whether and when this issue will be fixed. But I believe that workaround I suggested should works in your case.

Best regards.

OK. The work around does work for this case in particular. I will see if it holds up for other high volumn scenarios. Thx for the response!

The issues you have found earlier (filed as 5346) have been fixed in this update.