80070001 Incorrect function. (Exception from HRESULT: 0x80070001)

Getting below error when invoking code:

CODE:
Dim app As NetOffice.ExcelApi.Application
Dim wbSource As NetOffice.ExcelApi.Workbook


app = New NetOffice.ExcelApi.Application


wbSource = app.Workbooks.Open(FileXLSX)


wbSource.SaveAs(FileXLS,TYPE)


wbSource.Close()
app.Quit

ERROR:
RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ā€”> RemoteException wrapping System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID **
{
** 00024500-0000-0000-C000-000000000046

}failed due to the following error: 80070001 Incorrect function. (Exception from HRESULT: 0x80070001).

@Jerome_Cabutotan1

Iā€™m not sure about the issue.,
You can do that following the below steps

  1. Read the xlsx file and store the data into datatable
  2. Then write the same data table to xls file
    else

if you want working code for this, use this

    Dim excel As Microsoft.Office.Interop.Excel.Application
    Dim wb As Microsoft.Office.Interop.Excel.Workbook
    Dim ws As Microsoft.Office.Interop.Excel.Worksheet 
    excel = New Microsoft.Office.Interop.Excel.Application
    wb = excel.Workbooks.Open("FILEPATH", [ReadOnly]:=False) 'Open the excel the file'
    excel.Visible = True
    wb.SaveAs("FILEPATH")
    wb.Close()
    excel.Quit()
1 Like

thanks for the reply @HareeshMR. Forgot to mention, it works in some machine so I guess the problem is on ms excel setting?