MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Pausing a macro


Posted by Joe C on October 04, 2001 7:32 AM

Currently I am using this to pause my macro
newhour = Hour(Now())
newminute = Minute(Now())
newsecond = Second(Now()) + 1

waittime = TimeSerial(newhour, newminute, newsecond)
Application.Wait waittime
Is there a better command


Posted by faster on October 04, 2001 7:46 AM

depending on your needs, you might be able to use:


MsgBox "Pause message here"

Posted by Jerid on October 04, 2001 11:55 AM

You could use the Windows API.

Place this line in a code module:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Use this in you code to stop your application:
Sleep (10000)
This example would be 10000 milliseconds or 10 seconds, one minute would be 60000

Hope this helps.

Jerid

Posted by faster on October 04, 2001 1:10 PM

For Jerid


Cool stuff. Where can I find a good resource to
help with other API calls?

Posted by Jerid on October 05, 2001 3:56 AM

Re: For Jerid

Go to http://www.allapi.net/ and download their API-Guide

It's the best reference I’ve found so far.

Jerid


Posted by Joe C on October 05, 2001 5:04 AM

Thank you both.
Sleedp command worked perfectly.

Posted by faster on October 05, 2001 5:39 AM

Re: For Jerid

Looks like a lot of good stuff. I could always
see the function name, but couldn't find the
parameters. Many thanks.