Error Opening Word Doc in C#.Net: Command Failed

G

GPrabaka

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top