Wait in word macro

Hi,
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?

Cheers,

Shane.
PrimedWebbieAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
        DoEvents
    Loop
    Debug.Print "End " & Now
End Sub

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


Chris
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

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wobbledCommented:
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
0
PrimedWebbieAuthor Commented:
Didn't fix the issue as Requested but did work for another solution.
0
Chris BottomleySoftware Quality Lead EngineerCommented:
PrimedWebbie:

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!).

Chris
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.