LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default MACROS WONT RUN


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
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
Macros Wont Run After Hiding Sheet John Calder New Users to Excel 2 May 6th 09 11:14 PM
security med-but still wont open with macros Ian Elliott Excel Discussion (Misc queries) 1 March 17th 09 11:10 PM
Wont keep changes PauleyG Excel Programming 1 July 30th 08 12:16 AM
Date format from excel to CVS file wont. Change in CVS wont stay. Fish''s Mermaid Excel Worksheet Functions 1 October 14th 06 12:28 AM
Macros wont run?? tallpaul[_2_] Excel Programming 2 June 25th 06 05:30 PM


All times are GMT +1. The time now is 06:50 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"