VBA equivalent for WScript.Sleep

G

Guest

Hi,

I need to pause my code periodically. When I use Application.Wait or Timer
function, the processor usage goes to about 50% all the time the sub is
paused, but I need something like WScript.Sleep from VBScript that will pause
execution without affecting processor usage.
Any help is appreciated.
 
G

Guest

You can use ontime

Sub Main
Your code here
Application.OnTime Now() + 0.000694444 , "NextPart"
End Sub

Sub NextPart
Rest of code here
End Sub

The 0.000694444 = 1 minute
 
D

Dave Peterson

There's a Sleep API, too:

Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Sub testme()
sleep 500 'half second
end sub
 
G

Guest

Thanks guys

--
urkec


Dave Peterson said:
There's a Sleep API, too:

Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Sub testme()
sleep 500 'half second
end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top