Closing workbook without saving changes

  • Thread starter Thread starter EP
  • Start date Start date
E

EP

I tried ------

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Close SaveChanges:=False
End Sub

in Excel97 on a Win98 PC and it didn't work. I still got prompted to save
the changes.

So I tried ---------

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
End Sub

and it works perfectly.

I have transferred the workbook to a laptop running Excel 2000 and Win XP.
For some reason the "Saved = True" method doesn't seem to have any effect
and I am getting the Yes/No/Cancel message box again. I haven't yet had a
chance to try the "SaveChanges = False" alternative - but then, it didn't
work the last time!
Any ideas on all of this?

Eric
 
Try in macro in the MODULE:

Sub Auto_Close()
ThisWorkbook.Close SaveChanges:=False
End Sub
 
Back
Top