?
Solved

Outlook VBA + put pause in code

Posted on 2011-03-09
4
Medium Priority
?
3,354 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 1000 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 1000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

840 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