title: Proper VBA code to close workbook without saving
body: <p>Whenever the code is executed while multiple workbooks are open, office stops working with a message</p>
  <blockquote>
  <p>Microsoft Office Excel has stopped working</p>
  <p>Windows can try to recover your information and restart the program.</p>
  </blockquote>
  <p>What's wrong with the code? I'm using MS Office 2007 on Windows7</p>
  <pre><code>Private Sub Workbook_BeforeClose(Cancel As Boolean)
      close_without_saving
  End Sub
  
  Sub close_without_saving()
      Application.DisplayAlerts = False
      ThisWorkbook.Saved = True
  
      If Application.Workbooks.Count &lt; 2 Then
          Application.Quit
      Else
          ThisWorkbook.Close
      End If
  End Sub
  </code></pre>