+ Reply to Thread
Results 1 to 22 of 22

Not show interrupt dialog when pressing ESC

Hybrid View

sherrylongview Not show interrupt dialog... 05-31-2012, 04:33 PM
rvasquez Re: Not show interrupt dialog... 05-31-2012, 04:40 PM
sherrylongview Re: Not show interrupt dialog... 05-31-2012, 04:46 PM
sherrylongview Re: Not show interrupt dialog... 06-01-2012, 09:07 AM
JosephP Re: Not show interrupt dialog... 05-31-2012, 04:45 PM
JosephP Re: Not show interrupt dialog... 06-01-2012, 09:11 AM
sherrylongview Re: Not show interrupt dialog... 06-01-2012, 09:18 AM
rvasquez Re: Not show interrupt dialog... 06-01-2012, 09:39 AM
sherrylongview Re: Not show interrupt dialog... 06-01-2012, 09:46 AM
JosephP Re: Not show interrupt dialog... 06-01-2012, 09:45 AM
JosephP Re: Not show interrupt dialog... 06-01-2012, 09:48 AM
sherrylongview Re: Not show interrupt dialog... 06-01-2012, 09:54 AM
JosephP Re: Not show interrupt dialog... 06-01-2012, 09:57 AM
sherrylongview Re: Not show interrupt dialog... 06-01-2012, 10:04 AM
JosephP Re: Not show interrupt dialog... 06-01-2012, 10:15 AM
sherrylongview Re: Not show interrupt dialog... 06-01-2012, 10:20 AM
JosephP Re: Not show interrupt dialog... 06-01-2012, 10:30 AM
sherrylongview Re: Not show interrupt dialog... 06-01-2012, 10:32 AM
rvasquez Re: Not show interrupt dialog... 06-04-2012, 10:24 AM
JosephP Re: Not show interrupt dialog... 06-04-2012, 12:04 PM
rvasquez Re: Not show interrupt dialog... 06-04-2012, 01:20 PM
sherrylongview Re: Not show interrupt dialog... 06-11-2012, 09:17 AM
  1. #1
    Registered User
    Join Date
    05-31-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    11

    Question Not show interrupt dialog when pressing ESC

    Hi,

    I have a VBA code to do calculation after opening an excel workbook, user stops calculation by pressing ESC button. An interrupt dialog pops up. But user does not want to see this dialog. User hopes to see calcuation is stopped without any dialog pops up.

    Is this possible?

    Thanks,

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Not show interrupt dialog when pressing ESC

    Could you just put a message box before the code that runs on the on open event?

    'if user says yes then update files
    If MsgBox("Update Files", vbYesNo) = vbYes Then
    
        'your code that was originally set to run on open here
    
    'if user selects no the open workbook normally and don't update files or run code
    Else
        Exit Sub
    End If

  3. #3
    Registered User
    Join Date
    05-31-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Not show interrupt dialog when pressing ESC

    Yes, I tried. Sometimes it can pop up a dialog what I programmed. But most time it still pops up the interrupt dialog. When I debug inside, it shows the entrance of XXCELL the function trying to fill data to cell. I added the porgrammed code inside of the function. But the debug stopped at the entrance of the function, no chance to run my code.

    I added Application.EnableCancelKey = xlErrorHandler
    to every function I can find in call stack. But interrupt dialog pops up at the XXCELL function line. like: Public Function xxCELL(xxx) As Variant

    Thanks for your reply.
    Last edited by sherrylongview; 05-31-2012 at 04:52 PM.

  4. #4
    Registered User
    Join Date
    05-31-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Not show interrupt dialog when pressing ESC

    Can anybody help me?

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Not show interrupt dialog when pressing ESC

    if the esc key is interrupting your code you can use
    On Error GoTo handleCancel 
    Application.EnableCancelKey = xlErrorHandler 
    MsgBox "This may take a long time: press ESC to cancel" 
    For x = 1 To 1000000 ' Do something 1,000,000 times (long!) 
     ' do something here 
    Next x 
     
    handleCancel: 
    If Err = 18 Then 
     MsgBox "You cancelled" 
    End If
    (taken from msdn)
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Not show interrupt dialog when pressing ESC

    is that a UDF that you are adding to the sheet or one that is already in there? I assume that when you added the application.enablecancelkey you actually had error handlers in those routines? you could try setting it to xldisabled as long as you are sure there are no runaway loops.

  7. #7
    Registered User
    Join Date
    05-31-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Not show interrupt dialog when pressing ESC

    I tried to add Application.EnableCancelKey = xlErrorHandler with On Error GoTo or Application.EnableCancelKey = xlDisabled, but both of them look have to chance to run because debug stopped at the entrance of function, and always this function. Customer creates worksheets and we put auto calculation after opening workbook. Sometimes the workbook is large and takes long time to calculate. Customer wants to stop calculation after opening workbook. They use ESC, but interrupt dialog always pops up. They do not want to see it.

  8. #8
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Not show interrupt dialog when pressing ESC

    Hey there,

    I don't understand why the messagebox wouldn't work on the on open event. That way the user could choose to update files or not. This way if the user didn't need or want to update the files then the code would not run if they did want to then they could let the code run. You could put a warning in the msgbox stating it may take a long time to process.

  9. #9
    Registered User
    Join Date
    05-31-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Not show interrupt dialog when pressing ESC

    Even I put a dialog before doing calculation, user can choose yes. And later the calculation may take over 30 mins, and user changes his mind, he wants to stop calculation and do another stuff. How to stop it? press ESC, but interrupt dialog pops up. User do not want to see it, he just wants the calculation stops.

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Not show interrupt dialog when pressing ESC

    Workbook_Open would be too late for an initial calculation I think.

  11. #11
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Not show interrupt dialog when pressing ESC

    did you add the disabling of the cancel key to the function code as well? I've a feeling you might have no options with VBA-can you make a dll/xll instead?

  12. #12
    Registered User
    Join Date
    05-31-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Not show interrupt dialog when pressing ESC

    I tried to add Application.EnableCancelKey = xlDisabled in every function, but the problem is debug stops at entrance of function, Application.EnableCancelKey = xlDisabled has no chance to be run.
    My code is in VBA, the bug is for existing product, it is impossible to create a new dll. New dll can solve the problem?

  13. #13
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Not show interrupt dialog when pressing ESC

    yeah-if the code is in a dll then it's compiled as an executable and the debugger won't jump into it.

  14. #14
    Registered User
    Join Date
    05-31-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Not show interrupt dialog when pressing ESC

    I said the debug stops at the entrance of function, because I can enter the VBA code. For user, VBA code is encrypted, interrupt dialog shows with Continue, End, Debug, and Help buttons. For user, Debug button is diabled. For me, I can set it as enabled. When interrupt dialog pops up, I select Debug and go inside VBA code to see which function calls this interrupt dialog. And what I saw is always one function XXCELL calls it. I added Application.EnableCancelKey = xlDisabled in this function, but useless. Debug line is before Application.EnableCancelKey = xlDisabled code.

  15. #15
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Not show interrupt dialog when pressing ESC

    encrypted is not the same as compiled. your code is not in a dll.

  16. #16
    Registered User
    Join Date
    05-31-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Not show interrupt dialog when pressing ESC

    now it is impossible to put code in a dll. This is an issue, I cannot change the structure of code.

  17. #17
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Not show interrupt dialog when pressing ESC

    I'm out of ideas then I'm afraid.

  18. #18
    Registered User
    Join Date
    05-31-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Not show interrupt dialog when pressing ESC

    This issue at my hand is over a week.
    Nobody had the similar problem?

  19. #19
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Not show interrupt dialog when pressing ESC

    Hey there!

    Okay I think I got it!

    Try adding this to your code

    On Error GoTo ErrorHandler
    Application.EnableCancelKey = xlErrorHandler
    
    'your code
    
    ErrorHandler:
    If Err.Number = 18 Then
        Exit Sub
    End If
    
    end sub
    Let me know if it works for you!

  20. #20
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Not show interrupt dialog when pressing ESC

    ain't that what I said in post #3? ;-)

  21. #21
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Not show interrupt dialog when pressing ESC

    Sure did JosephP lol sorry wasn't paying attention

  22. #22
    Registered User
    Join Date
    05-31-2012
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Not show interrupt dialog when pressing ESC

    Thank you guys still on my question. But I still have not solved it

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1