Ralph,
The only way I can think of is to write a COM Add-In (CAI) and in the
AddinInstance_OnDisconnection event, test the value of RemoveMode. If it is
equal to ext_dm_HostShutdown ( = 0), then Excel is shutting down. If it is
<> 0, then the user closed the add-in and Excel is not shutting down.
I just wrote up a quick and dirty COM Add-In in VB6 to produce a log of the
Excel environment (workbooks open, add-ins, etc) to test the order of what
is getting closed when, and the CAI is getting unloaded before workbooks are
closed. Thus, you could put code in the OnDisconnection event of a CAI to do
whatever needs to be done in your application when Excel shuts down.
If you want a copy of the VB6 code (you can also write CAIs in VBA using the
same source code as in VB6), send me an email. I'll probably write something
about this on my web site in the next day or two.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
"RFraley" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a workbook that invokes the Workbook_BeforeClose sub routine when
>shutting down. I would like to change the behavior of this routine
>dependant upon whether the closing of the workbook is associated with the
>shutting down of Excel (version 2003).
>
> Thanks in advance for any assistance with this question.
>
> Ralph
>