My Error:
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
My Code:
if (FileExtension == ".xls")
{
string NewFileLocation = string.Empty;
NewFileLocation = string.Format("{0}{1}", FileLocation, "x");
if (System.IO.File.Exists(NewFileLocation))
System.IO.File.Delete(NewFileLocation);
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
excelApp.Visible = false;
Microsoft.Office.Interop.Excel.Workbook eWorkbook = excelApp.Workbooks.Open(FileLocation, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
eWorkbook.SaveAs(NewFileLocation, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
eWorkbook.Close(false, Type.Missing, Type.Missing);
FileLocation = NewFileLocation;
FileExtension = ".xlsx";
}