+ Reply to Thread
Results 1 to 4 of 4

{Esc} out of loop

  1. #1
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    {Esc} out of loop

    Here's what I would like to do:

    Run a sub with Application.OnTime that beeps once a second for 60 seconds (so if I'm not next to my computer, I will hear it beeping and check it out).
    Then when I press the {Esc} key the beeping will stop. It can be some other key - I use {Esc} because it's intuitive to press it to get out of something.

    Here's how I have it working now.

    Please Login or Register  to view this content.
    This works ok EXCEPT when I'm working in another workbook when the "beeper" goes off. The {Esc} gets sent to the activeworkbook, not the one that has myBeeper() in it, and I can't change to the "beeper" workbook, so I have to wait the whole 60 seconds for myBeeper() to finish.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: {Esc} out of loop

    Hey foxguy, you're making me laugh. I don't see a question mark anywhere in your above post. Did you have a question sir?

    I think this is all a part of windows being able to multitask. When you press ESC which application is supposed to service it?

    DLL, Romper, snb or Leith are your best bet on this question.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: {Esc} out of loop

    Your beep sub needs to use application.onkey to assign a macro to the ESC key. All that macro needs to do is set a boolean variable which gets checked inside your loop. I'd also add doevents inside the loop.
    Remember what the dormouse said
    Feed your head

  4. #4
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: {Esc} out of loop

    Hi Romper;

    Thanks. I never thought of assigning a macro to a key.


    Hi Marvin;

    When my beeper is running I want the workbook that contains the sub to service the {Esc}. Which was my problem, I couldn't figure out how to get a workbook in the background to grab the {Esc} away from the activeworkbook, so I was stuck waiting for the macro to end. Hopefully Romper's idea will solve my problem.

+ 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