Solved

Outlook VBA + put pause in code

Posted on 2011-03-09
4
2,553 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Welcome to part one of a multi-part tutorial series, VBScript for Windows System Administrators.  The goal of this series is to teach non-programmers how to write useful VBS code to automate their environment, and perform tasks faster, and in a more…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now