title: Cannot access read-only document .xlsx
body: <p>I have a datagrtidview.
  I created a button "Export datagridview to Excel"</p>
  
  <p>Below is the code for the export:</p>
  
  <pre><code> Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  
      Dim xlApp As Excel.Application
      Dim xlWorkBook As Excel.Workbook
      Dim xlWorkSheet As Excel.Worksheet
      Dim misValue As Object = System.Reflection.Missing.Value
  
  
      xlApp = New Excel.Application
      xlWorkBook = xlApp.Workbooks.Add(misValue)
      xlWorkSheet = xlWorkBook.Sheets("Sheet1")
  
      xlWorkSheet.SaveAs("C:\Masterlist.xlsx")
      xlWorkBook.Close()
      xlApp.Quit()
  
      releaseObject(xlApp)
      releaseObject(xlWorkBook)
      releaseObject(xlWorkSheet)
  
      MsgBox("You can find the file in C:\Masterlist.xlsx")
  End Sub
  </code></pre>
  
  <p><strong>I have also included reference: Microsoft.Office.Interop.Excel</strong></p>
  
  <p>However when I finished my project as an application, I install my application on other computer and this happens when I click on "Export to Excel" button:</p>
  
  <p><a href="https://i.stack.imgur.com/F45Q5.png" rel="nofollow noreferrer">https://i.stack.imgur.com/F45Q5.png</a></p>
  
  <p>What code that can disable read-only?
  Or any code here that makes this error appears?</p>
  
  <p>Thanks!</p>