View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Closing Workbook without Saving

Here you go, try this:

Sub Workbook_BeforeClose(Cancel As Boolean)

ThisWorkbook.Saved = True
ThisWorkbook.Close

End Sub

-----Original Message-----
Hi..

I'm attempting to write some code that will simply

prevent
a workbook from saving changes and close (without any
display alerts) when the "X" is clicked.

Tried this:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

ThisWorkbook.Close SaveChanges:=False

End Sub

however this results in Excel crashing...you can't select
a cell in the underlying workook that becomes the active
once this file closes. If you attempt to select another
sheet in it - crash..!!

Any help appreciated - I run Excel 2000

Rgds

Chris
.