code execution has been interupted - Excel 2003

D

David_W

After using ctr alt Break to stop a macro mid flow it continues to pop up and
break code running. Even after I have closed the workbook and try to run the
code in normall fashion this error message constantly re appears. Only after
pressing continue ~ 50 do we return to normall.

Can only assume this is a known bug with the application - but any thoughts
on resolutions / fixes.

Regards, David
 
J

Jim Cone

David,
Depending on how your code is written/structured, pressing Escape
or Ctrl + Break will only interrupt your code not stop it.
There is a "reset" button on the Standard and Debug menu bars in the
VBE which will do just that. (looks like a dark square)
Also, take a look in help for the "EnableCancelKey" property.
Make sure to read all of the remarks.
Finally, be aware that overall error handling settings are found in...
Tools | Options | General (tab) in the VBE.
--
Jim Cone
Portland, Oregon USA



"David_W"
<[email protected]>
wrote in message
After using ctr alt Break to stop a macro mid flow it continues to pop up and
break code running.
Even after I have closed the workbook and try to run the
code in normall fashion this error message constantly re appears.
Only after pressing continue ~ 50 do we return to normall.

Can only assume this is a known bug with the application - but any thoughts
on resolutions / fixes.
Regards, David
 
C

Chip Pearson

You should use the EnableCancelKey property to specify what is to be
done if the user breaks out of the code.


Application.EnableCancelKey = xlDisabled
' Dangerous. You can't break out
' of a rogue loop without using CTRL ALT DELETE

Application.EnableCancelKey = xlInterrupt
' Sloppy. opens the VBE on the break line.
' Users will be confused.

Application.EnableCancelKey = xlErrorHandler
' Best solution:

On Error GoTo ErrH:
'''''
' your code here
'''''

ErrH:
If Err.Number = 18 Then
MsgBox "Break Key Pressed"
If Err.Number <> 0 Then
MsgBox "Some other error" & vbCrLf & Err.Description
Else
' no error. do nothing.
End If

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

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

Top