Free Support Forum - aspose.com

Unspecified error while opening Word document containing page header and chart

Hi There,


I am creating a word document using a template with Aspose.Words.dll 15.5.0.0. Following are the steps of tasks that I am performing while generating document programmatically:
  1. Open template file using Aspose api.
  2. Dynamically create a merge field.
  3. Save the document.
  4. Reopen the document using OOXML.
  5. Create a chart using OOXML because Aspose doesn’t provide editable chart feature in Word.
  6. Replace the merge field using OOXML.
  7. Save and close the document.

Now When I open the document from the hard disk, It gives me following error:

‘We’re sorry.We can’t open “Document.docx” because we found a problem with itscontents.’
“Details”
“Unspecified Error”
"Location: Part: /word/header1.xml, line: 1, column: 0"

In my investigation, I have found below few points:

1. The above error occurs when I have text in page header in template and I create a chart as well.
If I don’t create a chart in document, this error doesn’t occur. Or, If I remove page header and create a chart, the error doesn’t occur.

2. When I remove either of the two (ie. page header and chart), it works. There is no error at all while opening the document. The above error occurs when I have both page header and chart in my document.

Note: This error started coming when I updated my Aspose.Words.dll from version 14.1.0.0 with new version 15.5.0.0. It works perfectly when I use Aspose.Words.dll 14.1.0.0.

I have attached my sample project and error.png as well for your reference. Please look into this and help me out.


Many Thanks,
Kavita

Hi Kavita,

Thanks for your inquiry. I have tested the scenario using Aspose.Words v15.5.0.0 and v14.1.0.0 and have checked the code shared by you. I have noticed that this issue is not related to Aspose.Words.

If you create the same template document (with simple text and mail merge merge field) using MS Word and execute only the OpenXml code, you will get the same output. In this scenario, no involvement of Aspose.Words. The output document still shows the same error message.

I have attached the Word template document with this post for your kind reference. This document is saved by MS Word 2013. Please let us know if you have any queries about Aspose.Words.