andre72
asked on
Converting Word Document using com at IIS using ASP.NET returns an error
Hi,
I developed a ASP.NET page that convert a word document to a HTML page.
This work fine at my development PC but at my server I get a message at the first line:
protected Microsoft.Office.Interop.W ord.Applic ationClass objApp = new Microsoft.Office.Interop.W ord.Applic ationClass (); reports:
Retrieving the COM class factory for component with CLSID
{000209FF-0000-0000-C000-0 0000000004 6} failed due to the following error:
80070005
Word ist installed right and also web.config reports no error:
<add assembly="Microsoft.Office .Interop.W ord, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E 9429C"/></ assemblies >
Ok, I found many hints at the net and understand that's access rights issue.
However I'm not able to fix it...
People suggest to change the com access rights using dcomcnfg but I can't find any word settings there ...
The server system:
Windows 2008 Server
Framework 3.5
Office 2007
Maybe somebody here can help me to make this work and have a solution for?
Thanks
Andre
I developed a ASP.NET page that convert a word document to a HTML page.
This work fine at my development PC but at my server I get a message at the first line:
protected Microsoft.Office.Interop.W
Retrieving the COM class factory for component with CLSID
{000209FF-0000-0000-C000-0
80070005
Word ist installed right and also web.config reports no error:
<add assembly="Microsoft.Office
Ok, I found many hints at the net and understand that's access rights issue.
However I'm not able to fix it...
People suggest to change the com access rights using dcomcnfg but I can't find any word settings there ...
The server system:
Windows 2008 Server
Framework 3.5
Office 2007
Maybe somebody here can help me to make this work and have a solution for?
Thanks
Andre
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm sorry, I tried it out and gave NETWORK SERVICE all rights for access, activation and start but the error is still the same ...
Yes I reduce the code to only only line as I think anything else will already work if I can create a new instance if the class.
However it's no secret I need to convert Word documents to HTML, maybe two or three every day
I think for this simple task is no thrid party modul needed also the code for convertion is ready just not runable at the server ...
Yes I reduce the code to only only line as I think anything else will already work if I can create a new instance if the class.
However it's no secret I need to convert Word documents to HTML, maybe two or three every day
I think for this simple task is no thrid party modul needed also the code for convertion is ready just not runable at the server ...
ASKER
I've installed IIS 7 however I gave ASPNET also the ame right but also this doesn't solve the problem ...
ASKER
Hundred tests later :-)
It seems that I can create a new instance when I include
But now I get an error at this line:
Microsoft.Office.Interop.W ord.Docume nt oDoc = objApp.ActiveDocument;
Exception:
Command not available as no document is loaded
Any idea how to fix this?
It seems that I can create a new instance when I include
<identity impersonate="true"/>
at web configBut now I get an error at this line:
Microsoft.Office.Interop.W
Exception:
Command not available as no document is loaded
Any idea how to fix this?
<%@ Page Language="C#" Debug="true"%>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Threading" %>
<script language="C#" runat="server">
protected Microsoft.Office.Interop.Word.ApplicationClass objApp = new Microsoft.Office.Interop.Word.ApplicationClass();
protected string strPathToUpload; //Path to upload files "Uploaded"
protected string strPathToConvert; //Path to convert uploaded files and save
object fltDocFormat = 10; //For filtered HTML Output
protected object missing = System.Reflection.Missing.Value;
protected object readOnly = false; //Open file in readOnly mode
protected object isVisible = false;//The process has to be in invisible mode
void Page_Load(object sender, EventArgs e)
{
string fName = "";
Page.Response.Write("<html>");
Page.Response.Write("<head>");
Page.Response.Write("</head>");
Page.Response.Write("<body>");
object wName = @"C:\inetpub\wwwroot\target\testfile.doc";
object hName = wName + ".html";
if (File.Exists(hName.ToString())) File.Delete(hName.ToString());
try
{
objApp.Documents.Open(ref wName,ref missing, ref readOnly, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing, ref missing, ref missing);
Page.Response.Write("Geladen");
}
catch(Exception ex)
{
Page.Response.Write(ex.Message);
}
objApp.Visible = false;
try
{
Microsoft.Office.Interop.Word.Document oDoc = objApp.ActiveDocument;
Page.Response.Write("Active");
}
catch(Exception ex)
{
Page.Response.Write(ex.Message);
}
// oDoc.SaveAs(ref hName, ref fltDocFormat, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
objApp.Quit(ref missing, ref missing, ref missing);
Page.Response.Write("</body>");
Page.Response.Write("</html>");
Page.Response.End();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body></body>
</html>
ASKER
Well some steps more needed but now it works fine. Thanks for your support
Did you ever figure out a solution to this. I have hunted and hunted and can find nothing. I would be more than happy to post a new question if you have an answer as well.
ASKER
Try DCOMConfg and set for DCM Word 97 - 2003 the tab Identy to "Interactive User". Also try this with C:\Windows\SysWOW64\comexp .msc .
If this doesn't solve the problem try <identity impersonate="true" userName="AnyAdmin" password="HisPassword" />
Qith this I make it work on every system ...
If this doesn't solve the problem try <identity impersonate="true" userName="AnyAdmin" password="HisPassword" />
Qith this I make it work on every system ...
Remember that IIS runs under a different account and so may not have acces to the file system.
Remember that the Visual Studio web server runs in your local user context, so when it shells out to Word that's why you can see it.
Also remember that Word is a single-threaded application and is not suitable for use in a multi-threaded web server environment. If you want to manipulate Word documents and send them back to the client in the browser I suggest that you buy a 3rd party component for your web server. Look at http://www.aspose.com and look at their Words product as a start.