View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bill Manville Bill Manville is offline
external usenet poster
 
Posts: 473
Default Closing Workbook without Saving

Chris Gorham wrote:
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


Try

Private Sub Workbook_BeforeClose(Cancel As Boolean)

ThisWorkbook.Saved = True

End Sub


Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup