View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 380
Default Help with Error Handlers!!!

That first example does not throw an error as the object is not declared, so
it is interpreted as a string and compared against "Nothing" and succeeds.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Conan Kelly" <CTBarbarin at msn dot com wrote in message
...
bob,

Thanks for the feed back, but please re-read the post.

I already knew that this syntax is incorrect (I stated that in the

comments). I intentionally had that in there to trigger a
legitimate error. That is not where the problem lies. When I have this

incorrect syntax in the code, the error handler works
correctly, BUT when I use [Ctrl] + [Break], the error handler does not

work correctly.

Any more thoughts on the matter will be greatly appreciated,

Conan




"Bob Phillips" wrote in message

...
If mrngCurrRange Is Nothing Then


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Conan Kelly" <CTBarbarin at msn dot com wrote in message
...
Hello all,

Using Excel 2002 (10.6501.6626) SP3

AAAAAAAAHHHHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!!!! THIS IS DRIVING ME

NUTS!!!!!!!!!!!!!!!!!!!!!!!!

I've been working on this for several days now and I think that I have

finally narrowed it down to this:

How can I get this to work correctly when I interrupt execution with

[Ctrl] + [Break]?


With the following code, the error handler works correctly:

Sub PasteReplaceNulls()
On Error GoTo PasteReplaceNulls_Err

Application.EnableCancelKey = xlErrorHandler

If mrngCurrRange = "Nothing" Then
' I KNOW THIS SYNTAX IS INCORRECT. I'VE ALREADY FOUND OUT

THE
CORRECT SYNTAX. This is just here to trigger a
legitimate error.
End If

'Statements that will cause the macro to run for a long time,

hence the need for "Application.EnableCancelKey =
xlErrorHandler" above

PasteReplaceNulls_Err:
MsgBox ActiveWorkbook.Name & vbCrLf & ActiveSheet.Name & vbCrLf

&
Selection.Address

Exit Sub

End Sub



BUT with the following code AND INTERRUPTING EXECUTION WITH [Ctrl] +

[Break], the error handler does not work correctly. Instead, I
get this error message:

http://home.att.net/~ctbarbarin/file...ress_error.jpg

Sub PasteReplaceNulls()
On Error GoTo PasteReplaceNulls_Err

Application.EnableCancelKey = xlErrorHandler

'Statements that will cause the macro to run for a long time,

hence the need for "Application.EnableCancelKey =
xlErrorHandler" above

PasteReplaceNulls_Err:
MsgBox ActiveWorkbook.Name & vbCrLf & ActiveSheet.Name & vbCrLf

&
Selection.Address

Exit Sub

End Sub




How can I get this to work correctly when I interrupt execution with

[Ctrl] + [Break]?

--
Thanks for any help anyone can provide,

Conan Kelly