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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Can't import password protected excel file in NAV 2015 using XlWrkBkReader

(0) ShareShare
ReportReport
Posted on by

I'm getting an error in NAV 2015 when trying to import an password protected NAV 2015 file, does anyone have any ideas on how to counter this?

*This post is locked for comments

I have the same question (0)
  • ManishS Profile Picture
    86 on at

    What is the error message ?

  • Community Member Profile Picture
    on at

  • Community Member Profile Picture
    on at

    http://imgur.com/VFhvMD3

  • Community Member Profile Picture
    on at

    It's falling over on this bit of code:

    XlWrkBkReader := XlWrkBkReader.Open(FileName);

  • Suggested answer
    Alexander Ermakov Profile Picture
    28,096 on at

    If you know the password, you can try to unprotect the file using xlWorkbook.Unprotect :  msdn.microsoft.com/.../microsoft.office.tools.excel.workbook.unprotect.aspx

    If you do not know the password, you need to remove protection, e.g. by external software which you can run in the background before opening, and use the result of that process.

  • Verified answer
    HILBE Profile Picture
    300 on at

    Yes, you have to open the file with the standard interop of excel and unprotect the sheet.

    ExcelApplicationClass_l := ExcelApplicationClass_l.ApplicationClass;

    ExcelWorkbook_l := ExcelApplicationClass_l.Workbooks.Open(FileName_v,0,TRUE,5,'','',TRUE,ExcelXLPlatform_l.xlWindows,'\t',FALSE,FALSE,0,TRUE,1,0);

    ExcelWorkbook_l.Unprotect('password');

    ExcelWorkbook_l.SaveAs(FileName_v,ExcelXLFileFormat_l.xlOpenXMLWorkbook,'','',FALSE,FALSE,ExcelXLSaveAsAccessMode_l.xlNoChange,ExcelXLSaveConflictResoultion_l.xlUserResolution,FALSE,'','',TRUE);

    ExcelWorkbook_l.Close(FALSE,FileName_v,FALSE);

    ExcelApplicationClass_l.Quit;

    After that you can read the file :)

    Parameter:

    Var Name DataType Subtype Length

    Ja FileName_v Text 1024

    local variables:

    Name DataType Subtype Length

    ExcelApplicationClass_l DotNet Microsoft.Office.Interop.Excel.ApplicationClass.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

    ExcelWorkbook_l DotNet Microsoft.Office.Interop.Excel.Workbook.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

    ExcelXLFileFormat_l DotNet Microsoft.Office.Interop.Excel.XlFileFormat.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

    ExcelXLPlatform_l DotNet Microsoft.Office.Interop.Excel.XlPlatform.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

    ExcelXLSaveAsAccessMode_l DotNet Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

    ExcelXLSaveConflictResoultion_l DotNet Microsoft.Office.Interop.Excel.XlSaveConflictResolution.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

    Hope it helps

  • Community Member Profile Picture
    on at

    That's great, thanks for taking the time to give me a thorough response, appreciate it!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans