View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.beginners
Jonathan West Jonathan West is offline
external usenet poster
 
Posts: 13
Default Beginners question: how to stop / abort execution of vba program


"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