how to Pause a VBA procedure until user presses Enter
Paul,
Can you not run the procedure and at the end prompt the
user to type the info into whichever cells and also set
the Enter key to run a second procedure using the OnKey
method? The second procedure would continue where the
first left off. At the end of the second procedure you
could reset the Enter key to normal using OnKey.
Alternatively, have the one procedure branch dependant on
the value of a module level or static variable. If the
variable equals 0 then run the first part and set it to 1
at the end of the first part. Then when the same procedure
is run again (by pressing the Enter key) it will run the
second part of the procedure. At the end of the second
part set the variable back to 0 and reset the Enter key to
normal.
Regards,
Greg
-----Original Message-----
Thanks for your reply, PC.
I suppose I should have mentioned that I'd like the user
to be able to do
some things in the host application while the VBA code is
paused.
Specifically, type some data. (Input Boxes and Message
Boxes won't work for
this, as I explained elsewhere in this threat).
If I create a loop that runs until the user takes some
action, such as press
the Enter key, which is what I would like, the running
VBA loop prevents the
user from doing anything else. So my user wouldn't be
able to do anything,
and thus, nothing is accomplished.
In effect, I'd like to somehow momentarily interrupt
(pause) execution of
the VBA code, while the user types several sentences of
text, and then
resume the VBA code as soon as the user presses the Enter
key.
Any ideas?
TIA
.
|