Close workbook without saving data


Posted by Lewis on November 09, 2001 3:18 PM

As part of my error trapping rooutine I need to close a workbook without saving data. If I use the ActiveWindow.Close command and there is data present I get a dialog box asking if I want to save the worksheet. I need to set the Save Property to True but I am not sure of the syntax.

Thanks in advance

Lewis



Posted by Dank on November 09, 2001 3:33 PM

What you need to do is set the Saved property to true e.g.

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

It will 'trick' Excel into thinking the workbook doesn't need saving and will avoid the dialog box you refer to.

HTH,
Daniel.