Macro for "close w/no save"?

  • Thread starter Thread starter Jerry C
  • Start date Start date
J

Jerry C

In Word, I have created a couple helpful macros and placed
them on the toolbar with an icon. The piggybank will
close the open document and save all changes. The garbage
can will close the document and NOT save any changes.
This precludes me having to respond to the "do you want to
save changes?" prompt each time (annoying!).

They work slick in Word.

Now, I'd like to have the same feature in Excel, but the
macro design or language is different and I can't figure
it out.

Here's the simple one-line of code for the "close no save"
macro (in Word):
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

What would be the equivilent in Excel?

Thanks in advance.

Jerry
 
-----Original Message-----
You can turn the alerts off...

Application.DisplayAlerts = False

I'm not sure that will solve it. With the alerts turned
off, what happens if I have a file I've made changes to,
and want to save the changes, and I click the "X" to close
it (without having saved it first)?

What I want to be able to do is to "close and save"
or "close and not save" with one click of the mouse.

Will turning off the alerts do that?

Jerry
 
whoops, didn't finish my point... something like this

Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = Tru
 
It is the same as word
Activeworkbook.Close SaveChanges:=False

ActiveWorkbook.Close SaveChanges:=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

Back
Top