title: Open Password Protected Excel Workbook C#
body: <p>I am trying to open a password protected Excel workbook. I have tried many different ways of unprotecting it programatically or inputting the password, yet every time my program runs, I m prompted to input the password. What am I doing wrong?</p>
  
  <pre><code> public class AttenFile
      {
          private Excel.Application excel;
          private Excel.Workbook wb;
          private Excel.Worksheet worksheet;
          private Excel.Range range;
          private const  int startRow = 3;
          private int row;
          private static Object MissingValue = System.Reflection.Missing.Value;
  
          public AttenFile(String attenFileDir)
          {
              excel = new Excel.Application();
              wb = excel.Workbooks.Open(attenFileDir, MissingValue, MissingValue, MissingValue, "nso" );
              wb.Unprotect("nso");
              worksheet = (Excel.Worksheet) wb.Sheets[1];
              worksheet.Unprotect("nso");
              range = worksheet.UsedRange;
          }
  }
  </code></pre>