ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   workbook_beforeClose (https://www.excelbanter.com/excel-programming/354586-workbook_beforeclose.html)

GB

workbook_beforeClose
 
For some reason, when closing excel, the code in my workbook_beforeClose
section (Located in "ThisWorkbook") does not run. I have the following
situation:
A personal.xls file located in my XLStart folder.
The file runs the workbook_Open routine when opened.
The only worksheet is hidden so that there is no associated worksheet for
the user to interact with.
Excel opens a separate workbook with the expected number of blank worksheets.
I can open, edit, and process other files on which I want to use the macros
in my personal.xls.
When closing excel by choosing the 'X' in the upper corner, all other
applications process properly, however the beforeclose event in my
personal.xls file does not get run. I have added a stop command in the code
to attempt debugging, and also a breakpoint as so desired, but it stops at
neither of these.

What is wrong with my logic?

There are some commands that I would like to process prior to closing the
personal.xls file and would have to come up with some other method if I can
not resolve this.

V/R,
GB

Jim Thomlinson[_5_]

workbook_beforeClose
 
Your observation appears to be correct. The before close event does not seem
to trigger out of the personal.xls workbbok. Very curious. That being said
you can use an Auto_close routine that will fire... In a standard code module
add the following...

Sub Auto_Close()
MsgBox "Tada"
End Sub

That seems to work.
--
HTH...

Jim Thomlinson


"GB" wrote:

For some reason, when closing excel, the code in my workbook_beforeClose
section (Located in "ThisWorkbook") does not run. I have the following
situation:
A personal.xls file located in my XLStart folder.
The file runs the workbook_Open routine when opened.
The only worksheet is hidden so that there is no associated worksheet for
the user to interact with.
Excel opens a separate workbook with the expected number of blank worksheets.
I can open, edit, and process other files on which I want to use the macros
in my personal.xls.
When closing excel by choosing the 'X' in the upper corner, all other
applications process properly, however the beforeclose event in my
personal.xls file does not get run. I have added a stop command in the code
to attempt debugging, and also a breakpoint as so desired, but it stops at
neither of these.

What is wrong with my logic?

There are some commands that I would like to process prior to closing the
personal.xls file and would have to come up with some other method if I can
not resolve this.

V/R,
GB


GB

workbook_beforeClose
 
Thanks, I had done a search for AUTOOPEN and AUTOCLOSE but not Auto_close.
Thank you. It worked when I went ahead and put it in a separate module, and
made my Workbook_BeforeClose event Public. (Saved me some time in rewriting,
will evaluate the necessity later.

"Jim Thomlinson" wrote:

Your observation appears to be correct. The before close event does not seem
to trigger out of the personal.xls workbbok. Very curious. That being said
you can use an Auto_close routine that will fire... In a standard code module
add the following...

Sub Auto_Close()
MsgBox "Tada"
End Sub

That seems to work.
--
HTH...

Jim Thomlinson


"GB" wrote:

For some reason, when closing excel, the code in my workbook_beforeClose
section (Located in "ThisWorkbook") does not run. I have the following
situation:
A personal.xls file located in my XLStart folder.
The file runs the workbook_Open routine when opened.
The only worksheet is hidden so that there is no associated worksheet for
the user to interact with.
Excel opens a separate workbook with the expected number of blank worksheets.
I can open, edit, and process other files on which I want to use the macros
in my personal.xls.
When closing excel by choosing the 'X' in the upper corner, all other
applications process properly, however the beforeclose event in my
personal.xls file does not get run. I have added a stop command in the code
to attempt debugging, and also a breakpoint as so desired, but it stops at
neither of these.

What is wrong with my logic?

There are some commands that I would like to process prior to closing the
personal.xls file and would have to come up with some other method if I can
not resolve this.

V/R,
GB



All times are GMT +1. The time now is 06:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com