Reputation: 343
Exception Details: System.Runtime.InteropServices.COMException: Word was unable to read this document. It may be corrupt. Try one or more of the following:
- Open and Repair the file.
- Open the file with the Text Recovery converter.] Microsoft.Office.Interop.Word.Documents.Add(Object& Template, Object& NewTemplate, Object& DocumentType, Object& Visible) +0
When running the solution through IIS on app server I'm getting this error. It's working fine in local. Tried both: changing Microsoft Word 97 - 2003 Document Authentication to none in DCOM Config and Interactive user permissions in security. And all required permissions are provided to the IIS user.
Upvotes: 0
Views: 751
Reputation: 31
Strange solution, but we solved the problem by creating this folder: C:\Windows\SysWOW64\config\systemprofile\Desktop
Upvotes: 0
Reputation: 7522
Please ensure that the account running the website has enough privilege to open a word document. In IIS
, change the identity attribute of the application pool used by the application to LocalSystem
.
Besides, check some other possible reasons.
https://www.systoolsgroup.com/updates/how-to-fix-word-was-unable-to-read-document-it-may-be-corrupt/
Feel free to let me know if there is further progress.
Upvotes: 0
Reputation: 343
Adding IIS user as an admin on app server resolved the issue.
Refer below URL to add a new user/admin on windows server. https://social.technet.microsoft.com/wiki/contents/articles/13436.windows-server-2012-how-to-add-an-account-to-a-local-administrator-group.aspx
Upvotes: 1
Reputation: 49395
The Considerations for server-side Automation of Office states the following:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
You need to use components designed for the server-side execution if you want to deal with old (doc) file format. Otherwise, you are free to utilize the Open XML SDK
, see Getting started with the Open XML SDK 2.5 for Office for more information.
Upvotes: 0