+ Reply to Thread
Results 1 to 6 of 6

HELP-HOW to Pause macro until user Keystoke

  1. #1
    Registered User
    Join Date
    01-18-2005
    Posts
    3

    HELP-HOW to Pause macro until user Keystoke

    wow, I figure the answer must be simple but I can't seem to figure it out.
    I need to pause the macro so that the user can visually verify a column of data, then press a defined key (Enter for example) to continue the macro on its way.
    I can see how to pause the macro for a specified time, but not indefinately until a user physically presses a key.
    Thanks so much...

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Quote Originally Posted by ectoid
    wow, I figure the answer must be simple but I can't seem to figure it out.
    I need to pause the macro so that the user can visually verify a column of data, then press a defined key (Enter for example) to continue the macro on its way.
    I can see how to pause the macro for a specified time, but not indefinately until a user physically presses a key.
    Thanks so much...
    Hello Ectoid,

    Like your user name. The easiest way would be to use a message box to pause the macro. Unless having this on the screen is objectionable. The user can move the box if it is obstructing their view and the macro won't pick up again until the user is responds. the are ways to do this without a message box or form, but are much more complex and advanced.

    Hope this helps,
    Leith Ross

  3. #3
    Registered User
    Join Date
    01-18-2005
    Posts
    3
    Hey thanks Leith...I guess I was converging on that. I don't mind having the message box as long as it can be a boolean Yes/No user response. I know how to have the user enter data using Inputbox, but I'd rather have them just click a button and then OK...

  4. #4
    Forum Contributor
    Join Date
    09-05-2004
    Location
    Melbourne
    Posts
    193
    You could possibly break your code into two and have the user activate the second portion of your code when he/she is ready. You could then use the onkey function for activating the second portion of your code. This allows for easier viewing/editing of the workbook.

    last line of code on first sub routine would look like this

    Application.OnKey "{RETURN}", "NextSub"
    Application.OnKey "{ESCAPE}", "ResetKeys"

    Sub NextSub()

    ResetKeys

    ........More code

    End Sub

    Sub ResetKeys()

    Application.OnKey "{RETURN}"
    Application.OnKey "{ESCAPE}"

    End Sub

    This way, the user could press either RETURN or ESC depending on whether he/she wants to continue of not.

    HTH

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    I was thinking of of Message Box with just an OK button and a message saying "Paused - Click OK to Resume"

    RetVal = MsgBox("Program Paused - Click OK to continue", vbOKOnly + vbInformation)

    You're call,
    Leieth Ross

  6. #6
    Registered User
    Join Date
    01-18-2005
    Posts
    3
    Thanks for the added info...Between the MsgBox and the split code, I've got a couple things to work with.
    Much appreciated...cheers!!!

+ 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