Results 1 to 7 of 7
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Stop code (Office XP SP3)

    hi

    I would like to use the Stop code.

    When I use the Stop code, this performs want I want to acheive & that is allows the pc & windows to refresh & catch up with the processing.

    However how do I resume or re-start the code?
    how does the 'pause' syntax work?

    Diana

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Stop code (Office XP SP3)

    Placing a Stop instruction in your code has the same effect as putting a breakpoint: when execution reaches the line with Stop, it will pause, allowing you to inspect the value of variables and properties. You can resume code execution by pressing F5 or selecting Run | Resume in the Visual Basic Editor. You can also press F8 repeatedly to execute the code step-by-step.

    Note: Stop is meant for the developer, to be able to check things when the code is still in development. You shouldn't leave Stop instructions in the definitive ('production') version of code.

  3. #3
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Stop code (Office XP SP3)

    Depending on what you mean by "allows the pc & windows to refresh & catch up", it may be that you want to use DoEvents rather than Stop. To quote the official Help page, "DoEvents passes control to the operating system. Control is returned after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent." With DoEvents, processing resumes automatically.

    In my experience, Office XP VB/VBA has been impressively good at not tripping over itself, so I've almost never had to make use of DoEvents, but there are a handful of places where it's been the essential cure.

  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stop code (Office XP SP3)

    Hi

    Yes I have DoEvents in my code....

    With Application
    ' Some other statement.... like PrintOut....
    Do While .BackgroundPrintingStatus > 0
    DoEvents
    If .BackgroundPrintingStatus <= 0 Then Exit Do
    Loop
    .ActiveDocument.Activate
    End With

    my code does the following:
    send a printed file to C:temp
    DoEvents
    open up the printer file & process
    after the file is completed processing then send the printer file to the printer.
    DoEvents

    end....

    for some reason its taking much too long to spool the file...when I was testing it on my WinNT 4.0 pc it was ok, however the issue has been picked up by another tester on a WinNT4.0 pc.

    I noticed that if I placed 'Stop' in the code & then resumed the code - the print job spooled at the expected speed.

    ive used the 'Sleep' code but the result is it makes no difference ie it still takes some time to spool

    any ideas?
    diana :-0

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Stop code (Office XP SP3)

    How about not using Background Printing?

  6. #6
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Stop code (Office XP SP3)

    hi

    yeah the Background Printing checkbox is cleared.

    diana

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Stop code (Office XP SP3)

    If you are not using background printing, the Application.BackgroundPrintingStatus should be zero and the DoEvents should never run. No?

    I think we've had a thread on two on how to have VBA pause until a file has been written out completely before proceeding. I can't remember the context, but maybe some searching and a bit of luck will turn it up?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •