Error Opening Word Doc in C#.Net Command Failed

gprabaka

Member
Joined
Jul 14, 2005
Messages
21
I am writing a webservice in C#.Net. I added the reference to Microsoft.Office.Interop.Word. When I attempt to do Documents.Open, I get the following error:

Can someone pleease help.
Thanks
Guha

Error
System.Runtime.InteropServices.COMException (0x800A1066): Command failed


The Code:
strWordTemplateFile = Server.MapPath(AppSettings.SupportingDocumentsLocation + "/LicenseOrderConfirmation.doc");
strWordDocumentFile = "c:\\temp\\LicenseOrderConfirmation.doc";
objWordDocumentFile = "c:\\temp\\LicenseOrderConfirmation.doc";

Microsoft.Office.Interop.Word.ApplicationClass objWord = new Microsoft.Office.Interop.Word.ApplicationClass();

System.IO.File.Copy(strWordTemplateFile,strWordDocumentFile,true);
object objVisible = false;
objWord.Visible = false;
objWord.Documents.Open(ref objWordDocumentFile,ref missing, ref missing, ref missing,ref missing,
ref missing,ref missing, ref missing, ref missing, ref missing, ref missing,
ref objVisible,ref missing,ref missing, ref missing, ref missing);
 
Office applications are simply not made to be run on a server...
This could be a permissions issue, or it could be an unfixable problem with automating Word on a server. Ive seen this problem mentioned before, but never seen a solution being proposed.

Articles that you should read:
INFO: Considerations for Server-Side Automation of Office
How To Configure Office Applications for Automation from a COM+/MTS Package
How to configure Office applications to run under a specific user account
How to configure Office applications to run under the interactive user account
 
Back
Top