Solved

Outlook VBA + put pause in code

Posted on 2011-03-09
4
2,488 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks for the help
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
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 …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
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.

762 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

11 Experts available now in Live!

Get 1:1 Help Now