Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how to pause execution for a few seconds

bhorngbhorng Member Posts: 3
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!!!

Comments

  • VB5begginnerVB5begginner Member Posts: 66
    : 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]



  • DarQDarQ Member Posts: 1,625
    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

  • DarQDarQ Member Posts: 1,625
    Euh, annotation in in milliseconds
    Greetz from DarQ

    --- Be sure to check ---
    http://www.aidix.cjb.net
    For info about AI stuff in VB

  • bhorngbhorng Member Posts: 3
    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
    :
    :

  • DarQDarQ Member Posts: 1,625
    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

  • bhorngbhorng Member Posts: 3
    Thanks much DarQ, it worked!!!

    : 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
    :
    :

  • DarQDarQ Member Posts: 1,625
    Nice to hear that...

    : Thanks much DarQ, it worked!!!
    :

    Greetz from DarQ

    --- Be sure to check ---
    http://www.aidix.cjb.net
    For info about AI stuff in VB

  • Shawn CarterShawn Carter Member Posts: 0

    _______ | http://forcoder.org | free video tutorials and ebooks about { Scratch, Swift, C#, R, Visual Basic, Java, PL/SQL, C, Delphi, Objective-C, C++, Visual Basic .NET, Go, MATLAB, Assembly, Python, Ruby, PHP, Perl, JavaScript Scala, SAS, Alice, COBOL, Rust, Transact-SQL, Crystal, ML, Bash, Awk, LabVIEW, Fortran, Ada, Scheme, Lisp, F#, Dart, Clojure, Kotlin, Logo, Prolog, Erlang, ABAP, Julia, VBScript, Hack, FoxPro, D, Lua, Apex } _

Sign In or Register to comment.