Excel Macro to Close Without Saving

K

Kass

I'm just starting to learn VBA. I want to make a macro
to close the active window and then not save. I have
template the user uses and then I need it to close and
not save so the template stays intact. I can get the
first part of the macro with ActiveWindow.Close. But
then the save prompt window shows up and I don't know how
to continue the macro so as to answer the prompt
with "NO" so as to close without saving. Thanks for your
help!

Kass
 
N

Nikos Yannacopoulos

Kass,

You're in the wrong NG for Excel!

Anyway, the answer is

ActiveWindow.Close False

Nikos
 
?

___

The answer to your question is...

Code
-------------------

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

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