View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.beginners
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Beginners question: how to stop / abort execution of vba program

But VBA ain't VB6, and all the things you mention are probably exactly what
he wants to happen, everything cleared down. The host application is still
running.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jonathan West" wrote in message
...

"Ardus Petus" wrote in message
...
Use the End instruction
Just End, not End Sub or End Function


In the VB6 newsgroups, that kind of advice can start a flamewar:-)

The problem with using End is well described in the VBA help file.

"Note The End statement stops code execution abruptly, without invoking
the Unload, QueryUnload, or Terminate event, or any other Visual Basic

code.
Code you have placed in the Unload, QueryUnload, and Terminate events of
forms and class modules is not executed. Objects created from class

modules
are destroyed, files opened using the Open statement are closed, and

memory
used by your program is freed. Object references held by other programs

are
invalidated.

The End statement provides a way to force your program to halt. For normal
termination of a Visual Basic program, you should unload all forms. Your
program closes as soon as there are no other programs holding references

to
objects created from your public class modules and no code executing."


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup