title: How to solve error: failed due to the following error: 80040154 Class not registered
body: <p>How to solve below error.
  This error getting at run time.</p>
  
  <blockquote>
    <p>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)).</p>
  </blockquote>
  
  <p>Code:
  This code is for convert word to pdf document file.
  I getting error at this line.</p>
  
  <pre><code>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;
          }
      }
  </code></pre>