View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Josh Sale Josh Sale is offline
external usenet poster
 
Posts: 177
Default Close All and Workbook_BeforeClose events

I've encountered the following problem that I wonder if anybody else has
encountered.

I have an application that is implemented as an Excel add-in. Each workbook
that contains application data contains a Workbook_BeforeClose event handler
that calls code in the add-in. If the user closes the workbook in any of
the typical ways, the event is raised and life is good.

However, if a user has two or more application workbooks open and then does
a File | Close All (accessed by holding down the Shift key when clicking the
File menu item) then the Workbook_BeforeClose event is only raised for the
active workbook ... even though all of the workbooks are being closed. As a
result, my application doesn't have a chance to cleanup after all of the
workbooks being closed.

I would have thought/hoped that Workbook_BeforeClose would be called for
each successive workbook (first making that workbook active since the event
doesn't provide the workbook as an argument).

Is anybody else surprised by this behavior?

Anybody got any good workarounds?

TIA,

josh