Close without saving

  • Thread starter Thread starter Brian Matlack
  • Start date Start date
B

Brian Matlack

Hi!
I have two workbooks open in the same application. I want to close one
without saving it. I use this code but it still asks me if I want to
save changes.

<Code start>
ActiveWindow.ActivateNext
ActiveWorkbook.Saved = False
ActiveWorkbook.Close
<End Code>

Can I use code that will close without saving and not ask if I want to
save changes?
Thanks!!
 
ActiveWorkbook.Saved = False is telling Excel that the workbook is not saved,
and so it is prompting with the "do you want to save..."

Try ActiveWorkbook.Saved = True; then you will tell Excel that it is already
saved and so Excel will think it is ok to close without saving.
 
Change the False to True on the Saved line. This tells Excel that there have
been no changes since the last save so that it will not prompt the user to
save again.

ActiveWorkbook.Saved = True
 
Back
Top