Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    shortcut keys to stop an endless code loop in Word (OfficeXP)

    Hey there

    In Word97 when there was an endless code loop in Word I use to press the shortcut keys CTRL PAUSE/BREAK.

    In WordXP when I want to end a code loop in Word if I use the same shortcut keys in Word > it doesnt respond.

    Can this still be done in XP? what are the shortcut keys?

    many thanks diana :-)

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

    Re: shortcut keys to stop an endless code loop in Word (OfficeXP)

    It's still Ctrl+Break. Perhaps you need to press it a few times to pause the code. You can also activate the Visual Basic Editor (Alt+F11) and click the Stop button on the toolbar.

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

    Re: shortcut keys to stop an endless code loop in Word (OfficeXP)

    thanks hans

  4. #4
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: shortcut keys to stop an endless code loop in Word (OfficeXP)

    Alt+F11 doesn't do the trick when you're in an endless loop with a msgbox, but Ctrl+Break does most of the time. If not, you can only get out with Ctrl+Alt+Del (and loose any changes after the last save). A few weeks ago, I learned that the hard way! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

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

    Re: shortcut keys to stop an endless code loop in

    thanks

    in my experience in XP, ive pressed the keys CTRL+ Break a number of times & the result it doesnt break my loop.
    i always have to CTRL+ALT+Delete to stop the code.

    next time ill apply the ALT+F11 key & see how i go.
    diana

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

    Re: shortcut keys to stop an endless code loop in

    Some loops don't give Windows any chance to monitor the keyboard. If you want to be able to break into a loop, consider including a statement

    DoEvents

    in the loop, for example:

    For i = 1 To 100000000
    ...
    ...
    DoEvents
    Next i

  7. #7
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Wellington, New Zealand
    Posts
    143
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: shortcut keys to stop an endless code loop in

    Has the ability to use CTRL + Break been disabled as part of the code?

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: shortcut keys to stop an endless code loop in

    > Can this still be done in XP?

    It can be done in any process, MSOffice or not, as long as it's something you wrote.

    I have taken to testing, within the loop, for a file on a removable drive. If the drive/disk is absent, the loop pauses or terminates under a controlled condition.

    Example: I'm processing 6,000 documents. Every 20th document (about one minute) the program tests for A:MyFile.txt. If it is not found, the program gracefully saves my restart point and accepts input from the user (me!).

    The overhead in testing a file is minimal in the life of the run; a floppy drive makes an excellent mechanical switch, independant of getting the attention of the CPU. Bonus, the floppy-drive "click" every two minutes reminds me that the beast is continuing its work.

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

    Re: shortcut keys to stop an endless code loop in

    yes ill have to check. how would i do that?

    diana :-)

  10. #10
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Wellington, New Zealand
    Posts
    143
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: shortcut keys to stop an endless code loop in

    Look for the following:

    Application.EnableCancelKey = wdCancelDisabled

    And in all modules, as until it's re-set by the following, it persists for the whole Word session (according to Word XP help):

    Application.EnableCancelKey = wdCancelInterrupt

  11. #11
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: shortcut keys to stop an endless code loop in Word (OfficeXP)

    Alt-F11 will enable you to get out of it BUT only if you pressed it *before* you got stuck in your endless code loop - in other words, if the VBE is open already when you get stuck, you can switch to it by clicking on the start bar; then you can use the 'stop' button in the VBE toolbar, but if you're already caught in the loop it will ignore attempts to open it with Alt-F11.

    I always try to keep the VBE open when working on code for that very reason!
    Beryl M


  12. #12
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: shortcut keys to stop an endless code loop in Word (OfficeXP)

    Tried that too Beryl, but it didn't work. When there's a msgbox on the screen, I cannot click on the Stop button in the toolbar in the VBE...

  13. #13
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: shortcut keys to stop an endless code loop in Word (OfficeXP)

    Hmmm ... yes, you're right; I just tried it.

    I don't know about XP (I've only got 97 here at work (so far)) but I just found that, with a msgbox on screen, if you press Ctrl-Break and then the X button top-right on the msgbox (not the ok button), the 'the code has been interrupted' Ctrl-break box came up as soon as the msgbox vanished - does that help?
    Beryl M


  14. #14
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: shortcut keys to stop an endless code loop in Word (OfficeXP)

    Yes! See my <post#=467739>post 467739</post#> earlier in this thread... <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  15. #15
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: shortcut keys to stop an endless code loop in Word (OfficeXP)

    Umm, I saw that; I was hoping that using Ctrl-Break in conjunction with the close X button of the msgbox might help with the few occasions when Ctrl-Break on its own wasn't enough?
    Beryl M


Page 1 of 2 12 LastLast

Posting Permissions

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