ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problems with Activeworkbook.Close (https://www.excelbanter.com/excel-programming/445334-re-problems-activeworkbook-close.html)

Tim Williams[_4_]

Problems with Activeworkbook.Close
 
On Feb 2, 9:18*pm, Terry wrote:
On Feb 2, 8:41*pm, Tim Williams wrote:

Why use workbook_activate rather than workbook_open ?


Not sure that would fix your problem but worth a try...


Tim


Actually, it is on open and not activate.

Wherever it is, it only exhibits this bizarre behavior if there is at
least one other workbook open.


Hard to suggest anything without seeing actual code.

Tim

Terry

Problems with Activeworkbook.Close
 
On Feb 3, 9:02*am, Tim Williams wrote:
On Feb 2, 9:18*pm, Terry wrote:

On Feb 2, 8:41*pm, Tim Williams wrote:


Why use workbook_activate rather than workbook_open ?


Not sure that would fix your problem but worth a try...


Tim


Actually, it is on open and not activate.


Wherever it is, it only exhibits this bizarre behavior if there is at
least one other workbook open.


Hard to suggest anything without seeing actual code.

Tim


I fixed it, it took a rather convoluted approach. What was happening
was after the Activeworkbook.Close the workbook_deactivate event would
invoke some of the common code which would effect changes in the
workbook being closed. This seemed to confuse Excel if there were any
other workbooks open.

What I did was determine at workbook_open time that I wanted to close
this workbook and set a global close flag.

At the end of the workbook_activate event I invoked the
Activeworkbook.Close method if my close flag was set.

Then at the end of the workbook_deactivate event I set
Activeworkbook.Saved=True if my close flag was set.

Now it works perfectly.


All times are GMT +1. The time now is 11:09 PM.

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