I wrote the code for: searching a word in a document that works without problems in the Console Application, but does not work in ASP.NET Application when I click the button:
using Microsoft.Office.Interop.Word;
Application objWordApp = new Application();
objWordApp.Visible = false;
object missing = System.Reflection.Missing.Value;
Document objDoc;
objDoc = objWordApp.Documents.Open(fileURL, 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, ref missing);
object findText = "Tags";
objDoc.Content.Find.ClearFormatting();
try
{
if (objDoc.Content.Find.Execute(ref findText,
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))
{
Console.WriteLine("Text found: Name document - " + "'" + docTitle + "'");
}
objDoc.Close(ref missing, ref missing, ref missing);
objWordApp.Application.Quit(ref missing, ref missing, ref missing);
}
catch (Exception ex)
{
objDoc.Close(ref missing, ref missing, ref missing);
objWordApp.Application.Quit(ref missing, ref missing, ref missing);
throw ex;
}
}
catch (Exception ex)
{
test11.Text = ex.ToString();
}
System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access denied. (Exception to HRESULT: 0x80070005 (E_ACCESSDENIED)).
I looked at a lot of information on the forums, did everything as written in the article, nothing helps, the error was not eliminated.
2.Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046}
Can you try this One
Step1:
Ref this link : Interop.Word Documents.Open is null
If you are still looking for the answer I have found it just a moment ago for my project.
Open DCOM Config Settings:
Start -> dcomcnfg.exe
Computer
Local Computer
Config DCOM
Search for Microsoft Word 97-2003 Documents -> Properties Tab Identity, change from Launching User to Interactive User
Step2:
Go to your Project do the below change..
Step3:
Go to the IIS Server, Add the Application Pool like a below Configuration and Map into to your site or application.
User contributions licensed under CC BY-SA 3.0