Articles | Photoshop blog | Photography blog | about me | e-mail

Helen Bradley - MS Office Tips, Tricks & Tutorials

Wednesday, June 18, 2008

Pause a Word macro

Sometimes you need tp pause a macro and, when you do, try the Sleep function.

This involves a call to the Windows API - sounds much more difficult than it is.

In your macro, go to the General Declarations area (the top part of the module) and type this, verbatim:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Now, in your routine, when you want to put a pause, type:

sleep n where n is the number of milliseconds to pause for.

So, this macro will beep, pause for 1000 milliseconds and beep again.. it does it twice just in case you missed it the first time:

sub testMyAPIcall()
beep
sleep 1000
beep
sleep 1000
beep
end sub

Easy when you know how!

Labels: ,

Add to Technorati Favorites

0 Comments:

Post a Comment

Please feel free to add your comment here. Thank you!

Subscribe to Post Comments [Atom]

<< Home