Outlook VBA + put pause in code

I would like to put in a pause of 30 seconds into my code is that possible in VBA, i have a loop and after that is done, i want the 30 second pause then continuing on.
dkilbyAsked:
Who is Participating?
 
Donald MaloneyConnect With a Mentor ConsultantCommented:
How about something like:

Dim PauseTime, Start, Finish
    PauseTime = 0.5  ' Set duration.  This is 1/2 second
    Start = Timer   ' Set start time.
    Do While Timer < Start + PauseTime
        DoEvents    ' Yield to other processes.
    Loop
    Finish = Timer  ' Set end time.   In case you want to know the end time
0
 
David LeeConnect With a Mentor Commented:
Hi, dkilby.

This will do it.
'Add this line at the top of a module outside of any procedure or function'
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

'Add this line of code wherever you want to sleep your code.  The time is in miliseconds, so remember to multiply the number of seconds you want it to sleep by 1000.'
Sleep 30000

Open in new window

0
 
David LeeCommented:
One additional thought.  Outlook runs on a single thread, so pausing code execution for 30 seconds is going to have an impact on other events taking place.  Long pauses are a bad idea.
0
 
dkilbyAuthor Commented:
thanks for the help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.