Jack Miller
Jack Miller

Reputation: 325

No xlOpenXMLWorkbook in interop

I have some code that is trying to convert a .xls spreadsheet into a .xlsx spreadsheet using Interop:

        public void Convert(string file)
    {


        var app = new Microsoft.Office.Interop.Excel.Application();
        var wb = app.Workbooks.Open(file);
        wb.SaveAs(Filename: file + "x", FileFormat: Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook);
        wb.Close();
        app.Quit();
    }

However I am receiving an error which says that xlopenxmlworkbook' is not a member of 'microsoft.office.interop.excel.xlfileformat'

Which leads me to beileive that I cannot save a .xls file because its a Excel 2003 file and .xlsx isn't supported by Excel 2003?

I have Office 2013 installed, so should not be a problem.

Is there a way to add xlopenxmlworkbook to the dll or update it? or another workaround?

Upvotes: 0

Views: 651

Answers (1)

ttaaoossuu
ttaaoossuu

Reputation: 7894

Just use the numeric value of xlOpenXMLWorkbook, which is 51.

Upvotes: 1

Related Questions