Executing code on exit. 
Author Message
 Executing code on exit.

VBA6

Is there a way to use some "handle" such that when a user clicks on
the close/exit box in the upper right corner of the main form of a VB6
program, some VBA code (a subroutine) can be called to execute before
the program exits?  What is the handle called?

I want to be sure that no matter how a user decides to quit, some
spawned instances of Excel are closed before the VB6 program exits.

The problem generally occurs when a user decides to quit the program
before he has finished making a "run," i.e., he just wants to dump
what he is doing right now and free up the resources -- or even shut
down.  If the spawned instances of Excel aren't killed when the
program is exited, they delay the shut down of the Operating System,
as one gets an error message that "Excel.exe is not responding!"

I know how to write the code to kill Excel; I just don't know how to
call it in the instance when the user clicks the close box.

Thanks,

Fred Holmes



Sat, 07 Jun 2003 04:09:06 GMT  
 Executing code on exit.

Use the UnloadMode value of the QueryUnload event -- its value will indicate
a system (control) menu close if the X or sysmenu Close option is
selected -- see the help file for exact values passed.

--

Randy Birch
MVP Visual Basic

Take the vb.net poll at:
http://www.mvps.org/vbnet/
http://www.mvps.org/ccrp/


: VBA6
:
: Is there a way to use some "handle" such that when a user clicks on
: the close/exit box in the upper right corner of the main form of a VB6
: program, some VBA code (a subroutine) can be called to execute before
: the program exits?  What is the handle called?
:
: I want to be sure that no matter how a user decides to quit, some
: spawned instances of Excel are closed before the VB6 program exits.
:
: The problem generally occurs when a user decides to quit the program
: before he has finished making a "run," i.e., he just wants to dump
: what he is doing right now and free up the resources -- or even shut
: down.  If the spawned instances of Excel aren't killed when the
: program is exited, they delay the shut down of the Operating System,
: as one gets an error message that "Excel.exe is not responding!"
:
: I know how to write the code to kill Excel; I just don't know how to
: call it in the instance when the user clicks the close box.
:
: Thanks,
:
: Fred Holmes



Sat, 07 Jun 2003 04:17:33 GMT  
 Executing code on exit.
you can check the msdn for the order of the events which are called when the
app is "over"...
you have the formunload and the queryunload...
usually the best place to locate yr code before terminating the application
is in the queryunload event..

orit

Quote:
> VBA6

> Is there a way to use some "handle" such that when a user clicks on
> the close/exit box in the upper right corner of the main form of a VB6
> program, some VBA code (a subroutine) can be called to execute before
> the program exits?  What is the handle called?

> I want to be sure that no matter how a user decides to quit, some
> spawned instances of Excel are closed before the VB6 program exits.

> The problem generally occurs when a user decides to quit the program
> before he has finished making a "run," i.e., he just wants to dump
> what he is doing right now and free up the resources -- or even shut
> down.  If the spawned instances of Excel aren't killed when the
> program is exited, they delay the shut down of the Operating System,
> as one gets an error message that "Excel.exe is not responding!"

> I know how to write the code to kill Excel; I just don't know how to
> call it in the instance when the user clicks the close box.

> Thanks,

> Fred Holmes



Sat, 07 Jun 2003 05:16:17 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Execute Code on Application Exit?

2. How do I code a menu Exit to exit

3. Can VB return exit code on program termination as exit(X) in C

4. How: end code (something like exit code in C)

5. another newbie question: exiting Formtool to execute a VB program

6. Execute db-command on server on exit

7. HELP !!!!! How to create exit Code

8. Code to Exit Outlook

9. Help with cell exit code

10. Problm while running the Project: The program has exited with code 0

11. vb_dotnet thread: Problems with VB.NET : The program has exited with code 0

12. get exit code of a process object

 

 
Powered by phpBB® Forum Software