I am writing a MS Word macro where I'd like the program pauses or delays for a specific interval. It seems to me a rather simple task but I couldn't figure it out.
: I am writing a MS Word macro where I'd like the program pauses or delays for a specific interval. It seems to me a rather simple task but I couldn't figure it out. : : Thanks for your kind help!!! :
im not exactly what youre trying to do but...depending on what you wanna do theres several ways...the safest way would be to add a Timer, but i dont know if Word supports timers...im not familar with VBA...to pause with code: [code] Dim PauseTime As Double, StartTime As Double PauseTime = [italic]Amount of Time[/italic] [green]'in seconds[/green] StartTime = Timer Do Until Timer >= StartTime + PauseTime [italic]Optional[/italic] DoEvents [green]'Depending on what you are trying 'to do you may or may not want to leave this out 'You will probably want to include this, because if you 'don't everything will freeze until the PauseTime is up 'this statement will stop it from freezing[/green] Loop[/code]
Thanks DarQ, but how I get Kernel32.dll, I don't even know what it is? Thanks
: private declare function sleep lib "Kernel32.dll" (lngTime as long) : : sleep 40 : : Voila!!! This should work... : Greetz from DarQ : : --- Be sure to check --- : http://www.aidix.cjb.net : For info about AI stuff in VB : :
: Ok, put this in a object module : : public declare sub Sleep lib "Kernel32" (ByVal dvMilliseconds as long) : : Now you have an extra sub available. Use Sleep [milliseconds] to activate the sleep sub. : : Kernel32.dll is always available in windows. This WILL work for sure! The previous reply i posted was wrong. : : ood luck : Greetz from DarQ : : --- Be sure to check --- : http://www.aidix.cjb.net : For info about AI stuff in VB : :
Comments
:
: Thanks for your kind help!!!
:
im not exactly what youre trying to do but...depending on what you wanna do theres several ways...the safest way would be to add a Timer, but i dont know if Word supports timers...im not familar with VBA...to pause with code:
[code]
Dim PauseTime As Double, StartTime As Double
PauseTime = [italic]Amount of Time[/italic] [green]'in seconds[/green]
StartTime = Timer
Do Until Timer >= StartTime + PauseTime
[italic]Optional[/italic] DoEvents [green]'Depending on what you are trying
'to do you may or may not want to leave this out
'You will probably want to include this, because if you
'don't everything will freeze until the PauseTime is up
'this statement will stop it from freezing[/green]
Loop[/code]
sleep 40
Voila!!! This should work...
Greetz from DarQ
--- Be sure to check ---
http://www.aidix.cjb.net
For info about AI stuff in VB
Greetz from DarQ
--- Be sure to check ---
http://www.aidix.cjb.net
For info about AI stuff in VB
: private declare function sleep lib "Kernel32.dll" (lngTime as long)
:
: sleep 40
:
: Voila!!! This should work...
: Greetz from DarQ
:
: --- Be sure to check ---
: http://www.aidix.cjb.net
: For info about AI stuff in VB
:
:
public declare sub Sleep lib "Kernel32" (ByVal dvMilliseconds as long)
Now you have an extra sub available. Use Sleep [milliseconds] to activate the sleep sub.
Kernel32.dll is always available in windows. This WILL work for sure! The previous reply i posted was wrong.
ood luck
Greetz from DarQ
--- Be sure to check ---
http://www.aidix.cjb.net
For info about AI stuff in VB
: Ok, put this in a object module
:
: public declare sub Sleep lib "Kernel32" (ByVal dvMilliseconds as long)
:
: Now you have an extra sub available. Use Sleep [milliseconds] to activate the sleep sub.
:
: Kernel32.dll is always available in windows. This WILL work for sure! The previous reply i posted was wrong.
:
: ood luck
: Greetz from DarQ
:
: --- Be sure to check ---
: http://www.aidix.cjb.net
: For info about AI stuff in VB
:
:
: Thanks much DarQ, it worked!!!
:
Greetz from DarQ
--- Be sure to check ---
http://www.aidix.cjb.net
For info about AI stuff in VB