Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Quick question on Error Trapping

So far in my short VBA programming experience, I have not done much in
the way of Error Trapping(I know that is a BAD thing). Lately, I've been
reading a few VBA books to learn more, and realized I need to code Error
Trapping.

In Excel 2002 Power Programming With VBA, by John Walkenbach, he
mentions that after using: On Error Resume Next, you need to restore
normal error handling with "On Error GoTo 0". My question is if the
current workbook is closed, without using the "On Error GoTo 0", is
error handling returned to normal? Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Quick question on Error Trapping

I think you misunderstand what John wrote regarding error
handling. To wit, it is NOT required that you use "On Error Goto
0" after an "On Error Resume Next". If you have an "On Error
Goto somewhere", then you DO need to use Resume or Resume Next
(or Exit Sub or End Sub) in your error handling block to restore
VBA's normal error handling.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






"Darrin Henshaw" wrote in message
...
So far in my short VBA programming experience, I have not done
much in
the way of Error Trapping(I know that is a BAD thing). Lately,
I've been
reading a few VBA books to learn more, and realized I need to
code Error
Trapping.

In Excel 2002 Power Programming With VBA, by John Walkenbach,
he
mentions that after using: On Error Resume Next, you need to
restore
normal error handling with "On Error GoTo 0". My question is if
the
current workbook is closed, without using the "On Error GoTo
0", is
error handling returned to normal? Thanks.

*** Sent via Developersdex http://www.developersdex.com ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Quick question on Error Trapping

It depends on what you mean by "current workbook." Do you mean the active
workbook, or the workbook containing the code?

Of course, once your macro is exited, error handling returns to normal.

--

Vasant


"Darrin Henshaw" wrote in message
...
So far in my short VBA programming experience, I have not done much in
the way of Error Trapping(I know that is a BAD thing). Lately, I've been
reading a few VBA books to learn more, and realized I need to code Error
Trapping.

In Excel 2002 Power Programming With VBA, by John Walkenbach, he
mentions that after using: On Error Resume Next, you need to restore
normal error handling with "On Error GoTo 0". My question is if the
current workbook is closed, without using the "On Error GoTo 0", is
error handling returned to normal? Thanks.

*** Sent via Developersdex http://www.developersdex.com ***



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Quick question on Error Trapping

Thanks Chip. In re-reading it, I understand how I interpreted it. I
thought it was like turning ScreenUpdating off, that in order for it to
work correctly, you need to turn it back on.

*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Quick question on Error Trapping

Error handling has local scope - so as soon as the procedure ends, any error
handling options are cleared.

--
Regards,
Tom Ogilvy

"Darrin Henshaw" wrote in message
...
So far in my short VBA programming experience, I have not done much in
the way of Error Trapping(I know that is a BAD thing). Lately, I've been
reading a few VBA books to learn more, and realized I need to code Error
Trapping.

In Excel 2002 Power Programming With VBA, by John Walkenbach, he
mentions that after using: On Error Resume Next, you need to restore
normal error handling with "On Error GoTo 0". My question is if the
current workbook is closed, without using the "On Error GoTo 0", is
error handling returned to normal? Thanks.

*** Sent via Developersdex http://www.developersdex.com ***



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
Error Trapping gazza67[_2_] Excel Discussion (Misc queries) 2 September 6th 07 06:11 PM
Trapping #VALUE! error RhysPieces Excel Discussion (Misc queries) 6 August 22nd 07 03:13 AM
Error Trapping from WSH Tom Chau Excel Discussion (Misc queries) 1 August 25th 06 04:21 AM
Error Trapping Andrew Excel Programming 1 April 5th 05 07:23 AM
error trapping libby Excel Programming 5 November 25th 03 10:57 PM


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

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

About Us

"It's about Microsoft Excel"