When i run the application from Visual Studio, word document is opening, but the same code if i open from IIS( Same Machine ) word document is not opening showing this error message
"Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 8000401a.".
Following is the code i am using to open and update the word document.
Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document aDoc = null;
if (File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/CMS/Lease/temp.doc")))
{
object readOnly = false;
object isVisible = false;
wordApp.Visible = false;
aDoc = wordApp.Documents.Open(ref filename, ref missing, ref readOnly, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing,
ref missing, ref missing, ref missing);
aDoc.Activate();
DataTable dtLease = BusinessLayer.CMS.Lease_Report(Convert.ToInt32(txtRec1.Text.Trim()), 1);
if (dtLease.Rows.Count > 0)
{
DataRow dr = dtLease.Rows[0];
string SupName = string.Empty;
if (dr["First_name"] != DBNull.Value && dr["Surname"] != DBNull.Value)
{
this.FindAndReplace(wordApp, "<deptrep>", (string)dr["First_name"] + " " + (string)dr["Surname"]);
}</deptrep>