Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Application.EnableCancelKey = xlDisabled Be VERY careful with that. If you get into an unintentional loop, you'll have to CTRL ALT DEL or TaskMgr to get out, and you'll lose data and possibly corrupt the workbook. A better approach is to set EnableCancelKey to xlErrorHandler. When the user breaks, VBA throws an Error 18, which you can detect and take the appropriate action. E.g., Application.EnableCancelKey = xlErrorHandler On Error GoTo ErrHandler ' ' your code here ' Exit Sub ErrHandler: If Err.Number = 18 Then ' break key hit. either ' get out, ' Resume to go back to the statement ' executing when Break was hit ' Resume Next to go back to the line ' after the line active when Break was hti ' prompt user for action then Resume Else ' some other error End If End Sub Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Wed, 19 Aug 2009 02:41:09 -0700 (PDT), dk wrote: On Aug 19, 1:28*am, JOSEPH WEBER wrote: I have several macros I use on *a daily basis and I tried to run them and they give me an error of "Code execution has been interrupted" *Can someone tell me why I could be getting this message? I didn't hit contrl break and have no idea what else i could have done wrong. * This happens most of the times when you offen debug using CTRL + BREAK, you put the following line in your macro: Application.EnableCancelKey = xlDisabled to avoid this. -DK |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macros Wont Run After Hiding Sheet | New Users to Excel | |||
security med-but still wont open with macros | Excel Discussion (Misc queries) | |||
Wont keep changes | Excel Programming | |||
Date format from excel to CVS file wont. Change in CVS wont stay. | Excel Worksheet Functions | |||
Macros wont run?? | Excel Programming |