title: saving data from c# to Excel crashes
body: <p>I work on a project where I'd like to save some data in an Excel sheet,</p>
  <p>Here is my code:</p>
  <pre class="lang-cs prettyprint-override"><code>private void myButton11_Click(object sender, EventArgs e)
  {
      Microsoft.Office.Interop.Excel.Application excel;
      Microsoft.Office.Interop.Excel.Workbook excelworkbook;
      Microsoft.Office.Interop.Excel.Worksheet excelsheet;
  
      excel = new Microsoft.Office.Interop.Excel.Application();
      excel.Visible = false;
      excel.DisplayAlerts = false;
  
      excelworkbook = excel.Workbooks.Add(Type.Missing);
  
      excelsheet = (Microsoft.Office.Interop.Excel.Worksheet)excelworkbook.ActiveSheet;
      excelsheet.Name = &quot;dataToExcel&quot;;
      // fill in data
      excelsheet.Cells[1, 1] = &quot;test&quot;;
      excelsheet.Cells[3, 3] = &quot;test2&quot;;
  
      // save excel
      excelworkbook.SaveAs(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + &quot;//dataToExcel.xls&quot;,
          Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal);
          true, true, 1, 10, false);
  }
  </code></pre>
  <p>The problem is when executing it crashes and shows me this error message:</p>
  <pre><code>System.Runtime.InteropServices.COMException
    HResult=0x800A03EC
    Message=Coudn't access file. Please try thoses options :
  
  • Make sure the file exist. 
  • Make sure the file is not in read only.
  • Make sure file path isn't containing thoses characteres:  &lt;  &gt;  ?  [  ]  :  | or  *
  • Make sure the file path and names do not take more than 218 caracteres.
  
  C:\Users\corentin.boudaud\source\repos\FabLoop_project_V0.0.0\FabLoop_project_V0.0.0\Program.cs :ligne 20
  
  </code></pre>
  <p>The crash occurs on &quot;SaveAs&quot;, the file I'm writing to is in my documents (public, write available)</p>
  <p>Any idea where the problem might come from?</p>
  <p>Thanks</p>