Re: how to Pause a VBA procedure until user presses Enter

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Vic Eldridge (vic_at_ultratrace.com.au)
Date: 06/09/04


Date: 8 Jun 2004 21:31:22 -0700

Hi Paul,

The following example should suit your requirements.

Regards,
Vic Eldridge

Sub Macro1()
    'Do some stuff...
    Range("A1") = "Macro1 Started"
    'Re-map the 2 Enter keys.
    Application.OnKey "{Enter}", "EnterKeyPress"
    Application.OnKey "~", "EnterKeyPress"
End Sub

Sub EnterKeyPress()
    'Reset the Enter keys to normal behaviour.
    Application.OnKey "{Enter}"
    Application.OnKey "~"
    Macro2
End Sub

Sub Macro2()
    'Do some more stuff...
    Range("A1") = "Macro2 Started"
End Sub

"Paul James" <pponzelliBEGONE@dfiSPAM.caFOREVER.gov> wrote in message news:<OPOG$OZTEHA.1548@TK2MSFTNGP11.phx.gbl>...
> Thanks for the suggestion, Bob. However Application.InputBox still confines
> you to entering any text in the InputBox without giving you the opportunity
> to enter data elsewhere. I need more flexibility than that.
>
>
> "Bob Phillips" <bob.phillips@notheretiscali.co.uk> wrote in message
> news:%23%23hE4qSTEHA.504@TK2MSFTNGP11.phx.gbl...
> > If you use Application.Inputbox, this operates in a way that allows
> further
> > action.
> >
> > --
> >
> > HTH
> >
> > Bob Phillips
> > ... looking out across Poole Harbour to the Purbecks
> > (remove nothere from the email address if mailing direct)
> >
> > "Paul James" <pponzelliBEGONE@SPAMsurewest.FOREVERnet> wrote in message
> > news:10cai8kfebet930@corp.supernews.com...
> > > Thanks for the reply, Vasant - Message Boxes won't work because I'm
> trying
> > > to enable the user to perform some actions before the code resumes.
> With
> a
> > > message box, the user can't perform any actions other than click a
> button
> on
> > > the message box to make it go away, but then the code resumes as soon as
> the
> > > message box closes, so I will have accomplished nothing.
> > >
> > > With an Input Box, the same limitations prevail, except that you get to
> type
> > > some text in the Input Box. Unfortunately, I need for the user to type
> more
> > > than a small string of text. Sometimes several sentences. But again, I
> > > want those sentenced typed at a very specific context, namely in the
> middle
> > > of a procedure that does other specific things before and after the user
> > > types those sentences.
> > >
> > > Any ideas how to accomplish this?
> > >
> > > Paul
> > >
> > >
> >
> >


Quantcast