Click here to Skip to main content
15,887,833 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am getting the following error while using the Interop word dll for converting the Word to PDF.

C#
Error Converting DOC To PDF12066_Parameter.docx Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).


Please suggest solutions ASAP.

What I have tried:

string strFileName = "";
strFileName = fuSrc.PostedFile.FileName.ToString();
Application appWord = new Application();
Document wordDocument = appWord.Documents.Open(strFileName);
txtDst.Text = strFileName.Replace(".docx", ".pdf").Replace(".doc", ".pdf");
try
{
wordDocument.ExportAsFixedFormat(txtDst.Text, WdExportFormat.wdExportFormatPDF);
lblErr.Text="Converted Successfully";
}
catch (Exception ex)
{
lblErr.Text=ex.Message.ToString();
}
Posted
Comments
Richard Deeming 1-Jun-16 11:32am    
Read the following Microsoft knowledgebase article:

Considerations for server-side Automation of Office[^]
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.


There are various hoops you'll have to jump through to stand any chance of getting Office Interop working from ASP.NET; and even if you do manage to get it working, there's no guarantee that it won't stop working at some random point in the future.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900