Wait in word macro

I am trying to invoke a wait command in a word macro but the Application.Wait or Wait doesn't work.

What is the code for making it wait for 10 seconds before proceeding further?


Who is Participating?
Chris BottomleySoftware Quality Lead EngineerCommented:
Alternatively when the delay is required terminate teh first sub but call up the continuation via ontime ...

Sub waitout1()
    Debug.Print "Start " & Now
    Application.OnTime Now + TimeValue("00:00:10"), "waitout2"
End Sub

Sub waitout2()
    Debug.Print "End " & Now
End Sub

Open in new window

Chris BottomleySoftware Quality Lead EngineerCommented:
One option is to use a loop i.e.

Sub waitout()
Dim when As Variant
    Debug.Print "Start " & Now
    when = Now + TimeValue("00:00:10")
    Do While when > Now
    Debug.Print "End " & Now
End Sub

The second option is a better way of adding a timed delay into your project as it does not involve the application looping through the code for the whole delay time, instead it just waits for the timer to kick off the next sub
PrimedWebbieAuthor Commented:
Didn't fix the issue as Requested but did work for another solution.
Chris BottomleySoftware Quality Lead EngineerCommented:

Please note I have requested a review to the "C" grade since as far as I know the posts implement a delay as asked - a valid answer would be you cannot do that but instead I gave actual alternatives which received a "C" grade.

Noting the guidance is:

Grading at Experts Exchange is not like school. It's more like the "10-point Must" system in professional boxing; in other words, an answer is worth an A, unless it doesn't resolve your issue. If it requires you to do a little more research, or figure out one more piece of code, then it's worth a B. If you think it's not worth a B, the custom is to offer the Experts an opportunity to earn a better grade.

There was no further communication and therefore since there was no request for further help, ("B" if you had to do more work and the expert ignored the further related help request) it really ought to be a "A" grade, (in my opinion!).

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.