encrypt an excel file with password without read only RRS feed

  • Question

  • Hello.

    I need the save as command of an excel work book in order to save a file with a password but dont allow read only.

    Only if you put the password you can open the file.

    I am using Microsoft.Office.Interop.Excel

    this is the command that i am using now but i can open to see the input if i press read only:


    • Moved by Sabah ShariqMVP Tuesday, January 3, 2017 2:08 PM Related to Microsoft Excel
    Tuesday, January 3, 2017 7:33 AM

All replies

  • Hi tom,

    This is Visual C# forum. As your issue is related to MS Excel I am moving your thread to MS Excel forum for getting quick response.

    Your understanding and cooperation will be grateful.

    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    Tuesday, January 3, 2017 2:08 PM
  • There is no value for the third parameter in your SaveAs command. This should be the Workbook password.

    MyApp.ActiveWorkbook.SaveAs(path, Microsoft.Office.Interop.Excel.XLFileFormat.xlOpenXMLWorkbook, MyPassword)

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Tuesday, January 3, 2017 2:12 PM
  • Here is an easy way to encrypt Excel workbook with password other than read-only. This method relies on free excel component.

    //load workbook
    Workbook book = new Workbook();
    //encrypt workbook with password
    //save to file 
    book.SaveToFile("encrypted_excel.xlsx", ExcelVersion.Version2013);

    Wednesday, January 4, 2017 2:42 AM