web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Converting XLS to XLSX File

(0) ShareShare
ReportReport
Posted on by 5,569

Hi

I'm trying to save XLS file as XLSX file using below code.
XlApp DotNet Microsoft.Office.Interop.Excel.ApplicationClass.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' 
XlWrkBk DotNet Microsoft.Office.Interop.Excel.Workbook.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' 
XlWrkSht DotNet Microsoft.Office.Interop.Excel.Worksheet.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' 
XlHelper DotNet Microsoft.Dynamics.Nav.Integration.Office.Excel.ExcelHelper.'Microsoft.Dynamics.Nav.Integration.Office, Version=10.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'  
ExcelXlSaveAsAccessMode DotNet Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' 
ExcelFileFormat DotNet Microsoft.Office.Interop.Excel.XlFileFormat.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' 

XlsFilename := C:\123.xls;
XlsxFilename := C:\123.xlsx;
XlApp := XlApp.ApplicationClass;
XlHelper.CallOpen(XlApp,XlsFilename);
XlWrkBk := XlApp.ActiveWorkbook;

XlWrkBk.SaveAs(XlsxFilename,ExcelFileFormat.xlWorkbookDefault,'','', FALSE, FALSE,
  ExcelXlSaveAsAccessMode.xlNoChange, FALSE, FALSE, FALSE, FALSE, FALSE);
XlWrkBk.Close(FALSE,'',TRUE);

but receiving the below error.

Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Binesh Profile Picture
    7,885 on at

    Hello Raj,

    see the bellow screenshot, this solution works perfectly. you can also use your old_filename with .xlsx 

    001.png

  • Rajasekhar@MS Profile Picture
    5,569 on at

    Hi

    Receiving this error, can you check in 2017(I think you are checking in 2016)

    Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))

  • Suggested answer
    Binesh Profile Picture
    7,885 on at

    Hey, i checked in NAV 2017. its working.

    only the thing is you have to re-declare the variables again.

    Better, Copy XlHelper variable from Table 370.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans