Upon error close workbook

  • Thread starter Thread starter robs3131
  • Start date Start date
R

robs3131

Hi all,

I'm trying to have my spreadsheet automatically close, without saving, upon
an error. Any idea on how to do this? Thanks!
 
The code

ThisWorkbook.Close SaveChanges:=False

will close the workbook that contains the code without doing a save. How to
trigger that code, and what you mean by "upon an error", isn't at all clear.
What type of error would you want to intercept? Any VBA runtime error?
Thinking more about this, I would recommend that you not try to do something
like this. There are many, many different errors that may arise in a
workbook, and I suspect that you really only want to act upon a very small
subset of possible errors. It would be very easy to lose a great deal of
work with such a blunt approach.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
Thanks for the code Chip. I'll take your input into consideration.
 

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