Dev Ashish posted something like this 8-years ago. I haven't
been using it because calls to sapiSleep() sub act more processor
intensive than those to VBA WaitFor() procedure. I'm reading
what you've written below, and it does seem logical. However,
I can grab windows by their title bars and move them around
whilst WaitFor'ing and I can't do that when sapiSleep'ing. Maybe
that seems contradictory to the documentation. But it's True. If
I'm WaitFor'ing say for 30-seconds, I can click the Database
window, open an object in design view then close it. On the other
hand, if I'm sapiSleeping for a similar time period, I cannot select
any other database object during that time. Nor can I grab the
form in which the sapiSleep procedure was Called by its Title Bar
and move around. Am pretty much lock out-a-doing anything
until the sapiSleep time period expires. Why is that?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxx
On 23 Jan 2007 10:08:59 -0800, "Lyle Fairfield"
<ly***********@aim.comwrote:
>The VBA While is not waiting for ten seconds. It is working for ten
seconds.
Declare Function Sleep& Lib "kernel32" (ByVal dwMillisecond&)
Private Sub Command0_Click()
Debug.Print Now()
Sleep 10000
Debug.Print Now()
End Sub
What we could hope is that this sleeps more soundly than the VBA
function; that is, the cpu usage is not 100% as it is with a VBA While
Procedure. And, of course, it does not need to check for pumpkins.
Documentation indicates it suspends operations only in the thread
wherein it is called; so the absence of DoEvents !!!!!SHOULD!!!!! not
be a problem.
SleepEx is an advanced function, that when used with ?????FileEx
functions can sleep for the entire time specified but return early if
an input or output operation completes.