We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Regarding Saving Document

hi,
I want to store the empty document but when i save the document it gives the error. i m using following code:

Dim document As WordDocument = New WordDocument()
document.Save("Sample.doc", Syncfusion.DocIO.FormatType.Doc)

I got following error:

Index was out of range. Must be non-negative and less than the size of the collection.

Can you plz guide me how to resolve this issue.

Thanks.

Gurpeet Madaan


3 Replies

BP Bhuvaneswari P Syncfusion Team July 2, 2008 05:46 AM UTC

Hi Gurpreet,

Thank you for your interest in Syncfusion products.

When we create a new empty document. It doesn't have any section or paragraphs, so it throws an error. To avoid this Call EnsureMinimal method, this will add one empty section and one empty paragraphs. Please refer the below code snippet:

VB

Dim document As WordDocument = New WordDocument()
document.Save("Sample.doc", Syncfusion.DocIO.FormatType.Doc)

'Adds one empty section to the document and one empty paragraph to created section.
doc.EnsureMinimal()


Please try this and let me know if this helps you.

Best Regards,
Bhuvana



AD Administrator Syncfusion Team June 30, 2009 12:17 PM UTC

I have had this same problem. After some trial and error approaches, I discovered that one field in the DataRow was causing the problem.

This field contained the text "H. " (including the space at the end).

When I removed the space, the problem was solved. As a work-around, I have now made sure that all fields of type string are trimmed before feeding it to DocIO, which solved the problem.


SS Sri Subhashini M Syncfusion Team July 1, 2009 12:03 PM UTC

Hi Michael,

Sorry for the inconvenience caused.

Could you please share us with sample code snippet or stack trace of the exception so that we could analyze the issue in depth and provide you the better solution?

Regards,
Suba

Loader.
Live Chat Icon For mobile
Up arrow icon