View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Terry Terry is offline
external usenet poster
 
Posts: 1
Default 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.