How do I pause or wait or sleep in VBA for Word?

In VBScript I use "Wscript.Sleep 1000" to pause my script for 1 second.  How do I do the same thing in VBA for Word?

Thanks
dougshepardAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
R_RajeshConnect With a Mentor Commented:
Your could also try the sleep funciton

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub mySub()
.
.
Sleep 1000 'pause for 1 second
.
.
End Sub

Rajesh
0
 
Anne TroyEast Coast ManagerCommented:
0
 
dougshepardAuthor Commented:
I am so confused.  All of that to pause for one second?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
byundtConnect With a Mentor Commented:
Hi dougshepard,
Word has both the Timer function and OnTime methods available for use.

From the on-line help for the Timer function:
This example uses the Timer function to pause the application. The example also uses DoEvents to yield to other processes during the pause.

Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then    'You can just set PauseTime to 1 if you don't want a message box
    PauseTime = 5    ' Set duration.
    Start = Timer    ' Set start time.
    Do While Timer < Start + PauseTime
        DoEvents    ' Yield to other processes.
    Loop
    Finish = Timer    ' Set end time.
    TotalTime = Finish - Start    ' Calculate total time.
    MsgBox "Paused for " & TotalTime & " seconds"
Else
    End
End If

The OnTime method schedules a macro to run at a certain time. It can be set up to run at constant intervals by merely resetting the alarm time for the next run. It is also discussed in Word's on-line help, but a better description is given (for Excel) by Chip Pearson at: http://www.cpearson.com/excel/ontime.htm

Cheers!

Brad
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
0
 
Anne TroyEast Coast ManagerCommented:
I deleted my lame comments. :) Shhh...
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Lame comments?  You have that luxury Dreamboat ;)
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.