Solved

Outlook VBA + put pause in code

Posted on 2011-03-09
4
2,652 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:dkilby
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
donaldmaloney earned 250 total points
ID: 35087580
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
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 250 total points
ID: 35089015
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
 
LVL 76

Expert Comment

by:David Lee
ID: 35089023
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
 

Author Closing Comment

by:dkilby
ID: 35095704
thanks for the help
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question