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

Helen Bradley - MS Office Tips, Tricks and Tutorials

I'm a lifestyle journalist and I've been writing about office productivity software for a long time. Here you'll find handy hints, tips, tricks, techniques and tutorials on using software as diverse as Excel, Word, PowerPoint, Outlook, Access and Publisher from Microsoft and other applications that I love. My publishing credits include PC Magazine, Windows XP mag, CNet, PC User mag, SmallbusinessComputing.com, Winplanet and Sydney Morning Herald.

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