Macro won't close file w/o displaying box to save changes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an excel macro that runs fine, however, at the end a box pops up asking if "I want to save the changes to the spreadsheet?". I do NOT want to save the changes that occur from the macro running, otherwise the spreadsheet will be ruined for the next use. I'm afraid I may accidentally click on "yes" and lose my original spreadsheet. Do you know of a line of VBA code that I can enter that will close the workbook and answer the question that I do not want to save the changes without the box popping up giving the user the opportunity to accept the changes?

Regards,
Jay
 
Jay, this will close the workbook without saving changes
ThisWorkbook.Close savechanges:=False

--
Paul B
Always backup your data before trying something new
Using Excel 97 & 2000
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **

Jay said:
I have an excel macro that runs fine, however, at the end a box pops up
asking if "I want to save the changes to the spreadsheet?". I do NOT want
to save the changes that occur from the macro running, otherwise the
spreadsheet will be ruined for the next use. I'm afraid I may accidentally
click on "yes" and lose my original spreadsheet. Do you know of a line of
VBA code that I can enter that will close the workbook and answer the
question that I do not want to save the changes without the box popping up
giving the user the opportunity to accept the changes?
 
you could put the code in to turn off display alerts and
then close the workbook and then turn back on your display
alerts:

Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True

Otherwise:
Your macro might have the code in it that makes the pop up
box that is asking you the question. If that is the case
you can delete that code.

-----Original Message-----
I have an excel macro that runs fine, however, at the end
a box pops up asking if "I want to save the changes to the
spreadsheet?". I do NOT want to save the changes that
occur from the macro running, otherwise the spreadsheet
will be ruined for the next use. I'm afraid I may
accidentally click on "yes" and lose my original
spreadsheet. Do you know of a line of VBA code that I can
enter that will close the workbook and answer the question
that I do not want to save the changes without the box
popping up giving the user the opportunity to accept the
changes?
 
For a non-programmatic solution see my post in
http://www.mrexcel.com/board2/viewtopic.php?t=67149&start=10
--
Regards,

Tushar Mehta
MS MVP Excel 2000-2003
www.tushar-mehta.com
Excel, PowerPoint, and VBA tutorials and add-ins
Custom Productivity Solutions leveraging MS Office


I have an excel macro that runs fine, however, at the end a box pops up asking if "I want to save the changes to the spreadsheet?". I do NOT want to save the changes that occur from the macro running, otherwise the spreadsheet will be ruined for the next use. I'm afraid I may accidentally click on "yes" and lose my original spreadsheet. Do you know of a line of VBA code that I can enter that will close the workbook and answer the question that I do not want to save
the changes without the box popping up giving the user the opportunity to accept the changes?
 
Back
Top