Results 1 to 8 of 8
  • Thread Tools
  1. 2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Quit Macro Execution (Word 2000 VBA)

    Okay, since I could not find any examples in the wonderful VBA documentation, what is the command to stop the macro execution? I have a simple OK/Cancel message box, if they choose cancel, I want the macro to end, you know , Quit.

    (I don't feel like a "Star" lounger right now...sigh)

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 13 Times in 13 Posts

    Re: Quit Macro Execution (Word 2000 VBA)

    Exit Sub or Exit Function,depending on whether you are writing a procedure (sub) or function.

  4. Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Quit Macro Execution (Word 2000 VBA)

    You can use
    EXIT SUB
    to leave the current subroutine

    I'm don't know how to exit from the current SUB and all its callers.

    StuartR

  5. 2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Quit Macro Execution (Word 2000 VBA)

    Thank you Hans and Stuart! (It's the little things that really bite me!)

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

    Re: Quit Macro Execution (Word 2000 VBA)

    Midges?

  7. 3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quit Macro Execution (Word 2000 VBA)

    The END statement stops all execution in the current thread.

  8. Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 13 Times in 13 Posts

    Re: Quit Macro Execution (Word 2000 VBA)

    End does indeed stop all execution, but it is very drastic: it clears all module-level variables and static local variables. Also, if you have a userform open, the standard events Unload, QueryUnload and Terminate are not fired, so any code for these events will not be executed. The End statement is a kind of emergency brake, only to be used in dire circumstances.

  9. 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: Quit Macro Execution (Word 2000 VBA)

    In that light, using functions with a return value indicating "get me out of here" would be a better design. But if we have Sub procedues, then perhaps global variables would be the next best thing...

Posting Permissions

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