Link to home
Start Free TrialLog in
Avatar of PrimedWebbie
PrimedWebbie

asked on

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.
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

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
ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of PrimedWebbie
PrimedWebbie

ASKER

Didn't fix the issue as Requested but did work for another solution.
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