Close without saving

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!!
 
G

Guest

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top