How to solve below error. This error getting at run time.
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
Code: This code is for convert word to pdf document file. I getting error at this line.
Application wordApp = new Microsoft.Office.Interop.Word.Application();
Document wordDocument = new Document();
private void ConvertWord2PDF(string inputFile, string outputPath)
{
try
{
if (outputPath.Equals("") || !File.Exists(inputFile))
{
throw new Exception("Either file does not exist or invalid output path");
}
// app to open the document belower
Application wordApp = new Microsoft.Office.Interop.Word.Application();
Document wordDocument = new Document();
// input variables
object objInputFile = inputFile;
object missParam = Type.Missing;
wordDocument = wordApp.Documents.Open(ref objInputFile, ref missParam, ref missParam, ref missParam,
ref missParam, ref missParam, ref missParam, ref missParam, ref missParam, ref missParam,
ref missParam, ref missParam, ref missParam, ref missParam, ref missParam, ref missParam);
if (wordDocument != null)
{
// make the convertion
wordDocument.ExportAsFixedFormat(outputPath, WdExportFormat.wdExportFormatPDF, false,
WdExportOptimizeFor.wdExportOptimizeForOnScreen, WdExportRange.wdExportAllDocument,
0, 0, WdExportItem.wdExportDocumentContent, true, true,
WdExportCreateBookmarks.wdExportCreateWordBookmarks, true, true, false, ref missParam);
}
// close document and quit application
wordDocument.Close();
wordApp.Quit();
Response.Write("File successfully converted");
//ClearTextBoxes();
}
catch (Exception e)
{
throw e;
}
}
Solution: Repair Microsoft Office Access You may need Administrator permissions to do this. It takes a while, but after Office and Access are repaired, the problem goes away. Confirm it's fixed by running Microsoft Access, opening a database, and testing CurrentProject. Connection in the Immediate Window.
In order to fix MSN error 80040154, re-register the MSXML3. dll file. If re-registering the file fails, install the latest version of the dynamic link library from the Microsoft Corporation in order to fix the problem.
According to users, “Class not registered” error appears when they try to open a . jpg file on their computer, and this problem can be fixed by resetting default apps. To do that, follow these instructions: Open Settings > Apps > Default apps.
no Office app should be used in a service or in a web-app, such as IIS. Secondly, interop.word.dll is like a header file and you actually need to have Office\word installed to be able to use it.
Please be warned of Microsoft's stance on this:
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.
Preview and convert Word files in ASP.Net -using OpenXML
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With