Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Upon error close workbook

Hi all,

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

--
Robert
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Upon error close workbook

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)



"robs3131" wrote in message
...
Hi all,

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

--
Robert


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Upon error close workbook

Thanks for the code Chip. I'll take your input into consideration.

--
Robert


"Chip Pearson" wrote:

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)



"robs3131" wrote in message
...
Hi all,

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

--
Robert


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot close a workbook in VBA due to Run-Time error '1004' Tom Med Excel Programming 3 September 24th 07 04:10 PM
Workbook close error Rich[_25_] Excel Programming 7 October 28th 04 12:25 AM
commandbar at workbook before close - run time error tango Excel Programming 1 October 24th 04 10:42 PM
commandbar at workbook before close - run time error tango Excel Programming 1 October 23rd 04 08:26 AM
When running workbook.close True Excel generates an error!!! Daniel[_10_] Excel Programming 2 May 11th 04 05:31 PM


All times are GMT +1. The time now is 12:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"