This is a migrated thread and some comments may be shown as answers.

Word experienced an error trying to open the file

3 Answers 225 Views
WordsProcessing
This is a migrated thread and some comments may be shown as answers.
Evan
Top achievements
Rank 1
Evan asked on 14 Aug 2019, 10:00 PM

I am trying to export my document but I am getting the error attached to the thread.

I can fix this by going into the properties of the document and checking the unblock box. Is there a way to do this in the export to be able to just open the document without having to go into its properties? I get the same error on the demo page for generating word documents https://demos.telerik.com/aspnet-ajax/wordsprocessing/generate-documents/defaultcs.aspx

 

Here is my code for export

RadFlowDocument document = report.GenerateDoc();             

DocxFormatProvider provider = new DocxFormatProvider();             

MemoryStream ms = new MemoryStream();             

provider.Export(document, ms);             

byte[] byteArray = ms.ToArray();             

ms.Dispose();             

return File(byteArray, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "AAR.docx");

 

3 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 19 Aug 2019, 08:44 AM
Hello Evan,

Using the provided code, I was able to successfully export a sample DOCX document. That is why my suggestion is that the error you are getting might be related to some content added to the document inside report.GenerateDoc(). Would it be possible to share its code so I can further investigate the case?

Regards,
Tanya
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Evan
Top achievements
Rank 1
answered on 19 Aug 2019, 01:42 PM

The code I have for generating the document is pretty long. I use sections for pages and I use paragraphs and tables. I do not think the error is related to the data that I am inserting because I get the same error from the demo page mentioned above. 

From what I can tell it is more on the word document side not trusting the source of where the document came from. The fix that I saw was to enter the url as a trusted url and it will always be able to be opened without going into the properties. I dont want to have the user to have to change something on their computer to be able to open a document.

 

If you have any more information about this it would be appreciated thanks.

0
Tanya
Telerik team
answered on 22 Aug 2019, 12:44 PM
Hello Evan,

As far as I understand, the file is being protected by MS Word due to security reasons. Please, correct me if I am wrong.

This protection can be forced when the file is downloaded from the internet and placed in a temporary folder. However, this is a behavior of the Microsoft application and I am afraid that there is no any setting which can affect that on document level.

Regards,
Tanya
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
WordsProcessing
Asked by
Evan
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Evan
Top achievements
Rank 1
Share this question
or