PC Review


Reply
Thread Tools Rate Thread

How can I detect that the user canceled a close?

 
 
=?Utf-8?B?VG9tVGh1bWI=?=
Guest
Posts: n/a
 
      20th Sep 2007
That is all I need to know: Just how can I obtain what is probably a boolean
value telling me the user canceled a close.
--
TomThumb
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      20th Sep 2007
"user canceled a close" - do you mean if user cancels Excel-quit or merely
while doing file-close, that might be relevant depending on your ultimate
objective. However in either case there is no direct method to return your
boolean if user cancelled close during the 'save unsaved file(s) prompt'.

I assume you want to know so as to determine whether or not to run your
close event code. One workaround is to run the close event as normal, but
also call a routine with the OnTime method to restore as-was. Eg with an
addins, might want to remove all menus as normal in the close event then put
them back again a few seconds later if the workbook is still open.

A different approach is to use a Com-addin. This has the advantage that its
close event only fires when Excel really is about to quit and won't be
cancelled. There are various ways to get the CAI to call a routine in the wb
to run close code 'only' if Excel and hence the file is about to close. I
believe Chip Pearson has made available on his site a CAI to do that, which
makes use of the 'hidden namespace'. I have a CAI that does similar but with
a different approach (doesn't use the namespace) if interested.

Regards,
Peter T

"TomThumb" <(E-Mail Removed)> wrote in message
news:65374B59-7DE8-4DC4-BAC8-(E-Mail Removed)...
> That is all I need to know: Just how can I obtain what is probably a

boolean
> value telling me the user canceled a close.
> --
> TomThumb



 
Reply With Quote
 
=?Utf-8?B?VG9tVGh1bWI=?=
Guest
Posts: n/a
 
      20th Sep 2007
Peter T:

Thank you for responding to my plea for help. I should have spelled out
what I have in mind:

I have an Add-In Toolbar that I delete in my WorkBookBeforeClose event
procedure. But when the user closes and then clicks "Cancel" when asked to
Save, the Close is terminated and the toolbar is gone. I want to restore
that toolbar, or not delete it in the first place.

Can I somehow get a boolean from WorkbookBeforeSave?
--
TomThumb


"Peter T" wrote:

> "user canceled a close" - do you mean if user cancels Excel-quit or merely
> while doing file-close, that might be relevant depending on your ultimate
> objective. However in either case there is no direct method to return your
> boolean if user cancelled close during the 'save unsaved file(s) prompt'.
>
> I assume you want to know so as to determine whether or not to run your
> close event code. One workaround is to run the close event as normal, but
> also call a routine with the OnTime method to restore as-was. Eg with an
> addins, might want to remove all menus as normal in the close event then put
> them back again a few seconds later if the workbook is still open.
>
> A different approach is to use a Com-addin. This has the advantage that its
> close event only fires when Excel really is about to quit and won't be
> cancelled. There are various ways to get the CAI to call a routine in the wb
> to run close code 'only' if Excel and hence the file is about to close. I
> believe Chip Pearson has made available on his site a CAI to do that, which
> makes use of the 'hidden namespace'. I have a CAI that does similar but with
> a different approach (doesn't use the namespace) if interested.
>
> Regards,
> Peter T
>
> "TomThumb" <(E-Mail Removed)> wrote in message
> news:65374B59-7DE8-4DC4-BAC8-(E-Mail Removed)...
> > That is all I need to know: Just how can I obtain what is probably a

> boolean
> > value telling me the user canceled a close.
> > --
> > TomThumb

>
>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      20th Sep 2007
Afraid all I can do is reiterate my previous response which, as it turns
out, appears to have fully anticipated your scenario and objective -

> Can I somehow get a boolean from WorkbookBeforeSave?


No, neither can you get it (user cancelled close) from any other event, at
least not directly.

> I want to restore that toolbar, or not delete it in the first place.


Try the workaround I suggested previously -
If working with VBA only, you will need to let your close event code run as
normally, ie delete your Toolbar. Then call your routine to add or restore
your toolbar with the Ontime method and a small delay. Five seconds should
be plenty, doesn't matter if user hangs around for more than that as it will
fire when allowed, assuming of course the workbook is still open, ie user
cancelled close.
Eg, add the following in your close event -

' in Workbook_BeforeClose or sub auto_close
Dim sMacro as string

code to delete toolbar, or call relevant routine to do that

sMacro = "AddToolBar"
sMacro = "'" & ThisWorkbook.Name & "'!" & sMacro
Application.Ontime Now + timeserial(0,0,5) sMacro ' adjust the 5 second
delay to suit

Put Sub AddToolBar() in a normal module with code to add or restore your
toolbar. This might be the same routine as called in the Open event. You can
include additional arguments in the macro string if necessary.

Alternatively try Chip Pearson's Com-addin
http://www.cpearson.com/excel/ExcelShutdown.htm
or as I mentioned I also have a Com-addin that employs some different
methods you're welcome to try if interested.

Regards,
Peter T

"TomThumb" <(E-Mail Removed)> wrote in message
news:7F367FEF-77C8-4D7F-9E78-(E-Mail Removed)...
> Peter T:
>
> Thank you for responding to my plea for help. I should have spelled out
> what I have in mind:
>
> I have an Add-In Toolbar that I delete in my WorkBookBeforeClose event
> procedure. But when the user closes and then clicks "Cancel" when asked

to
> Save, the Close is terminated and the toolbar is gone. I want to restore
> that toolbar, or not delete it in the first place.
>
> Can I somehow get a boolean from WorkbookBeforeSave?
> --
> TomThumb
>
>
> "Peter T" wrote:
>
> > "user canceled a close" - do you mean if user cancels Excel-quit or

merely
> > while doing file-close, that might be relevant depending on your

ultimate
> > objective. However in either case there is no direct method to return

your
> > boolean if user cancelled close during the 'save unsaved file(s)

prompt'.
> >
> > I assume you want to know so as to determine whether or not to run your
> > close event code. One workaround is to run the close event as normal,

but
> > also call a routine with the OnTime method to restore as-was. Eg with an
> > addins, might want to remove all menus as normal in the close event then

put
> > them back again a few seconds later if the workbook is still open.
> >
> > A different approach is to use a Com-addin. This has the advantage that

its
> > close event only fires when Excel really is about to quit and won't be
> > cancelled. There are various ways to get the CAI to call a routine in

the wb
> > to run close code 'only' if Excel and hence the file is about to close.

I
> > believe Chip Pearson has made available on his site a CAI to do that,

which
> > makes use of the 'hidden namespace'. I have a CAI that does similar but

with
> > a different approach (doesn't use the namespace) if interested.
> >
> > Regards,
> > Peter T
> >
> > "TomThumb" <(E-Mail Removed)> wrote in message
> > news:65374B59-7DE8-4DC4-BAC8-(E-Mail Removed)...
> > > That is all I need to know: Just how can I obtain what is probably a

> > boolean
> > > value telling me the user canceled a close.
> > > --
> > > TomThumb

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?VG9tVGh1bWI=?=
Guest
Posts: n/a
 
      20th Sep 2007
To Peter T:

Thanks for your help.


--
TomThumb


"Peter T" wrote:

> Afraid all I can do is reiterate my previous response which, as it turns
> out, appears to have fully anticipated your scenario and objective -
>
> > Can I somehow get a boolean from WorkbookBeforeSave?

>
> No, neither can you get it (user cancelled close) from any other event, at
> least not directly.
>
> > I want to restore that toolbar, or not delete it in the first place.

>
> Try the workaround I suggested previously -
> If working with VBA only, you will need to let your close event code run as
> normally, ie delete your Toolbar. Then call your routine to add or restore
> your toolbar with the Ontime method and a small delay. Five seconds should
> be plenty, doesn't matter if user hangs around for more than that as it will
> fire when allowed, assuming of course the workbook is still open, ie user
> cancelled close.
> Eg, add the following in your close event -
>
> ' in Workbook_BeforeClose or sub auto_close
> Dim sMacro as string
>
> code to delete toolbar, or call relevant routine to do that
>
> sMacro = "AddToolBar"
> sMacro = "'" & ThisWorkbook.Name & "'!" & sMacro
> Application.Ontime Now + timeserial(0,0,5) sMacro ' adjust the 5 second
> delay to suit
>
> Put Sub AddToolBar() in a normal module with code to add or restore your
> toolbar. This might be the same routine as called in the Open event. You can
> include additional arguments in the macro string if necessary.
>
> Alternatively try Chip Pearson's Com-addin
> http://www.cpearson.com/excel/ExcelShutdown.htm
> or as I mentioned I also have a Com-addin that employs some different
> methods you're welcome to try if interested.
>
> Regards,
> Peter T
>
> "TomThumb" <(E-Mail Removed)> wrote in message
> news:7F367FEF-77C8-4D7F-9E78-(E-Mail Removed)...
> > Peter T:
> >
> > Thank you for responding to my plea for help. I should have spelled out
> > what I have in mind:
> >
> > I have an Add-In Toolbar that I delete in my WorkBookBeforeClose event
> > procedure. But when the user closes and then clicks "Cancel" when asked

> to
> > Save, the Close is terminated and the toolbar is gone. I want to restore
> > that toolbar, or not delete it in the first place.
> >
> > Can I somehow get a boolean from WorkbookBeforeSave?
> > --
> > TomThumb
> >
> >
> > "Peter T" wrote:
> >
> > > "user canceled a close" - do you mean if user cancels Excel-quit or

> merely
> > > while doing file-close, that might be relevant depending on your

> ultimate
> > > objective. However in either case there is no direct method to return

> your
> > > boolean if user cancelled close during the 'save unsaved file(s)

> prompt'.
> > >
> > > I assume you want to know so as to determine whether or not to run your
> > > close event code. One workaround is to run the close event as normal,

> but
> > > also call a routine with the OnTime method to restore as-was. Eg with an
> > > addins, might want to remove all menus as normal in the close event then

> put
> > > them back again a few seconds later if the workbook is still open.
> > >
> > > A different approach is to use a Com-addin. This has the advantage that

> its
> > > close event only fires when Excel really is about to quit and won't be
> > > cancelled. There are various ways to get the CAI to call a routine in

> the wb
> > > to run close code 'only' if Excel and hence the file is about to close.

> I
> > > believe Chip Pearson has made available on his site a CAI to do that,

> which
> > > makes use of the 'hidden namespace'. I have a CAI that does similar but

> with
> > > a different approach (doesn't use the namespace) if interested.
> > >
> > > Regards,
> > > Peter T
> > >
> > > "TomThumb" <(E-Mail Removed)> wrote in message
> > > news:65374B59-7DE8-4DC4-BAC8-(E-Mail Removed)...
> > > > That is all I need to know: Just how can I obtain what is probably a
> > > boolean
> > > > value telling me the user canceled a close.
> > > > --
> > > > TomThumb
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
Doug Glancy
Guest
Posts: n/a
 
      21st Sep 2007
TomThumb,

Instead of the Open and BeforeClose events, look at using Activate and
Deactivate instead. When a workbook closes the Deactivate event fires after
the BeforeClose and the Cancel message. Also, then your toolbar will be
deleted when you switch to another workbook, which I'm guessing is also what
you want.

hth,

Doug

"TomThumb" <(E-Mail Removed)> wrote in message
news:7F367FEF-77C8-4D7F-9E78-(E-Mail Removed)...
> Peter T:
>
> Thank you for responding to my plea for help. I should have spelled out
> what I have in mind:
>
> I have an Add-In Toolbar that I delete in my WorkBookBeforeClose event
> procedure. But when the user closes and then clicks "Cancel" when asked
> to
> Save, the Close is terminated and the toolbar is gone. I want to restore
> that toolbar, or not delete it in the first place.
>
> Can I somehow get a boolean from WorkbookBeforeSave?
> --
> TomThumb
>
>
> "Peter T" wrote:
>
>> "user canceled a close" - do you mean if user cancels Excel-quit or
>> merely
>> while doing file-close, that might be relevant depending on your ultimate
>> objective. However in either case there is no direct method to return
>> your
>> boolean if user cancelled close during the 'save unsaved file(s) prompt'.
>>
>> I assume you want to know so as to determine whether or not to run your
>> close event code. One workaround is to run the close event as normal, but
>> also call a routine with the OnTime method to restore as-was. Eg with an
>> addins, might want to remove all menus as normal in the close event then
>> put
>> them back again a few seconds later if the workbook is still open.
>>
>> A different approach is to use a Com-addin. This has the advantage that
>> its
>> close event only fires when Excel really is about to quit and won't be
>> cancelled. There are various ways to get the CAI to call a routine in the
>> wb
>> to run close code 'only' if Excel and hence the file is about to close. I
>> believe Chip Pearson has made available on his site a CAI to do that,
>> which
>> makes use of the 'hidden namespace'. I have a CAI that does similar but
>> with
>> a different approach (doesn't use the namespace) if interested.
>>
>> Regards,
>> Peter T
>>
>> "TomThumb" <(E-Mail Removed)> wrote in message
>> news:65374B59-7DE8-4DC4-BAC8-(E-Mail Removed)...
>> > That is all I need to know: Just how can I obtain what is probably a

>> boolean
>> > value telling me the user canceled a close.
>> > --
>> > TomThumb

>>
>>
>>


 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      21st Sep 2007
Hi Doug,

The Deactivate & Activate events are not triggered in an addin, which as I
understand is what the OP wants to cater for.

Regards,
Peter T

"Doug Glancy" <(E-Mail Removed)> wrote in message
news:#TUK4NB$(E-Mail Removed)...
> TomThumb,
>
> Instead of the Open and BeforeClose events, look at using Activate and
> Deactivate instead. When a workbook closes the Deactivate event fires

after
> the BeforeClose and the Cancel message. Also, then your toolbar will be
> deleted when you switch to another workbook, which I'm guessing is also

what
> you want.
>
> hth,
>
> Doug
>
> "TomThumb" <(E-Mail Removed)> wrote in message
> news:7F367FEF-77C8-4D7F-9E78-(E-Mail Removed)...
> > Peter T:
> >
> > Thank you for responding to my plea for help. I should have spelled out
> > what I have in mind:
> >
> > I have an Add-In Toolbar that I delete in my WorkBookBeforeClose event
> > procedure. But when the user closes and then clicks "Cancel" when asked
> > to
> > Save, the Close is terminated and the toolbar is gone. I want to

restore
> > that toolbar, or not delete it in the first place.
> >
> > Can I somehow get a boolean from WorkbookBeforeSave?
> > --
> > TomThumb
> >
> >
> > "Peter T" wrote:
> >
> >> "user canceled a close" - do you mean if user cancels Excel-quit or
> >> merely
> >> while doing file-close, that might be relevant depending on your

ultimate
> >> objective. However in either case there is no direct method to return
> >> your
> >> boolean if user cancelled close during the 'save unsaved file(s)

prompt'.
> >>
> >> I assume you want to know so as to determine whether or not to run your
> >> close event code. One workaround is to run the close event as normal,

but
> >> also call a routine with the OnTime method to restore as-was. Eg with

an
> >> addins, might want to remove all menus as normal in the close event

then
> >> put
> >> them back again a few seconds later if the workbook is still open.
> >>
> >> A different approach is to use a Com-addin. This has the advantage that
> >> its
> >> close event only fires when Excel really is about to quit and won't be
> >> cancelled. There are various ways to get the CAI to call a routine in

the
> >> wb
> >> to run close code 'only' if Excel and hence the file is about to close.

I
> >> believe Chip Pearson has made available on his site a CAI to do that,
> >> which
> >> makes use of the 'hidden namespace'. I have a CAI that does similar but
> >> with
> >> a different approach (doesn't use the namespace) if interested.
> >>
> >> Regards,
> >> Peter T
> >>
> >> "TomThumb" <(E-Mail Removed)> wrote in message
> >> news:65374B59-7DE8-4DC4-BAC8-(E-Mail Removed)...
> >> > That is all I need to know: Just how can I obtain what is probably a
> >> boolean
> >> > value telling me the user canceled a close.
> >> > --
> >> > TomThumb
> >>
> >>
> >>

>



 
Reply With Quote
 
Doug Glancy
Guest
Posts: n/a
 
      21st Sep 2007
Peter T,

Then why is the user being prompted to save changes? I thought it was the
situation where the toolbar is created at workbook open and deleted at
close.

Doug

"Peter T" <peter_t@discussions> wrote in message
news:e7Q5pVC$(E-Mail Removed)...
> Hi Doug,
>
> The Deactivate & Activate events are not triggered in an addin, which as I
> understand is what the OP wants to cater for.
>
> Regards,
> Peter T
>
> "Doug Glancy" <(E-Mail Removed)> wrote in message
> news:#TUK4NB$(E-Mail Removed)...
>> TomThumb,
>>
>> Instead of the Open and BeforeClose events, look at using Activate and
>> Deactivate instead. When a workbook closes the Deactivate event fires

> after
>> the BeforeClose and the Cancel message. Also, then your toolbar will be
>> deleted when you switch to another workbook, which I'm guessing is also

> what
>> you want.
>>
>> hth,
>>
>> Doug
>>
>> "TomThumb" <(E-Mail Removed)> wrote in message
>> news:7F367FEF-77C8-4D7F-9E78-(E-Mail Removed)...
>> > Peter T:
>> >
>> > Thank you for responding to my plea for help. I should have spelled
>> > out
>> > what I have in mind:
>> >
>> > I have an Add-In Toolbar that I delete in my WorkBookBeforeClose event
>> > procedure. But when the user closes and then clicks "Cancel" when
>> > asked
>> > to
>> > Save, the Close is terminated and the toolbar is gone. I want to

> restore
>> > that toolbar, or not delete it in the first place.
>> >
>> > Can I somehow get a boolean from WorkbookBeforeSave?
>> > --
>> > TomThumb
>> >
>> >
>> > "Peter T" wrote:
>> >
>> >> "user canceled a close" - do you mean if user cancels Excel-quit or
>> >> merely
>> >> while doing file-close, that might be relevant depending on your

> ultimate
>> >> objective. However in either case there is no direct method to return
>> >> your
>> >> boolean if user cancelled close during the 'save unsaved file(s)

> prompt'.
>> >>
>> >> I assume you want to know so as to determine whether or not to run
>> >> your
>> >> close event code. One workaround is to run the close event as normal,

> but
>> >> also call a routine with the OnTime method to restore as-was. Eg with

> an
>> >> addins, might want to remove all menus as normal in the close event

> then
>> >> put
>> >> them back again a few seconds later if the workbook is still open.
>> >>
>> >> A different approach is to use a Com-addin. This has the advantage
>> >> that
>> >> its
>> >> close event only fires when Excel really is about to quit and won't be
>> >> cancelled. There are various ways to get the CAI to call a routine in

> the
>> >> wb
>> >> to run close code 'only' if Excel and hence the file is about to
>> >> close.

> I
>> >> believe Chip Pearson has made available on his site a CAI to do that,
>> >> which
>> >> makes use of the 'hidden namespace'. I have a CAI that does similar
>> >> but
>> >> with
>> >> a different approach (doesn't use the namespace) if interested.
>> >>
>> >> Regards,
>> >> Peter T
>> >>
>> >> "TomThumb" <(E-Mail Removed)> wrote in message
>> >> news:65374B59-7DE8-4DC4-BAC8-(E-Mail Removed)...
>> >> > That is all I need to know: Just how can I obtain what is probably
>> >> > a
>> >> boolean
>> >> > value telling me the user canceled a close.
>> >> > --
>> >> > TomThumb
>> >>
>> >>
>> >>

>>

>
>


 
Reply With Quote
 
=?Utf-8?B?VG9tVGh1bWI=?=
Guest
Posts: n/a
 
      21st Sep 2007
Doug & Peter T:

The WorkbookDeactivate event procedure did not remove the toolbar. The
Ontime works, but is problematic as I did get an error message once.

I need to get closer to close than WorkbookBeforeClose.

--
TomThumb


"Doug Glancy" wrote:

> Peter T,
>
> Then why is the user being prompted to save changes? I thought it was the
> situation where the toolbar is created at workbook open and deleted at
> close.
>
> Doug
>
> "Peter T" <peter_t@discussions> wrote in message
> news:e7Q5pVC$(E-Mail Removed)...
> > Hi Doug,
> >
> > The Deactivate & Activate events are not triggered in an addin, which as I
> > understand is what the OP wants to cater for.
> >
> > Regards,
> > Peter T
> >
> > "Doug Glancy" <(E-Mail Removed)> wrote in message
> > news:#TUK4NB$(E-Mail Removed)...
> >> TomThumb,
> >>
> >> Instead of the Open and BeforeClose events, look at using Activate and
> >> Deactivate instead. When a workbook closes the Deactivate event fires

> > after
> >> the BeforeClose and the Cancel message. Also, then your toolbar will be
> >> deleted when you switch to another workbook, which I'm guessing is also

> > what
> >> you want.
> >>
> >> hth,
> >>
> >> Doug
> >>
> >> "TomThumb" <(E-Mail Removed)> wrote in message
> >> news:7F367FEF-77C8-4D7F-9E78-(E-Mail Removed)...
> >> > Peter T:
> >> >
> >> > Thank you for responding to my plea for help. I should have spelled
> >> > out
> >> > what I have in mind:
> >> >
> >> > I have an Add-In Toolbar that I delete in my WorkBookBeforeClose event
> >> > procedure. But when the user closes and then clicks "Cancel" when
> >> > asked
> >> > to
> >> > Save, the Close is terminated and the toolbar is gone. I want to

> > restore
> >> > that toolbar, or not delete it in the first place.
> >> >
> >> > Can I somehow get a boolean from WorkbookBeforeSave?
> >> > --
> >> > TomThumb
> >> >
> >> >
> >> > "Peter T" wrote:
> >> >
> >> >> "user canceled a close" - do you mean if user cancels Excel-quit or
> >> >> merely
> >> >> while doing file-close, that might be relevant depending on your

> > ultimate
> >> >> objective. However in either case there is no direct method to return
> >> >> your
> >> >> boolean if user cancelled close during the 'save unsaved file(s)

> > prompt'.
> >> >>
> >> >> I assume you want to know so as to determine whether or not to run
> >> >> your
> >> >> close event code. One workaround is to run the close event as normal,

> > but
> >> >> also call a routine with the OnTime method to restore as-was. Eg with

> > an
> >> >> addins, might want to remove all menus as normal in the close event

> > then
> >> >> put
> >> >> them back again a few seconds later if the workbook is still open.
> >> >>
> >> >> A different approach is to use a Com-addin. This has the advantage
> >> >> that
> >> >> its
> >> >> close event only fires when Excel really is about to quit and won't be
> >> >> cancelled. There are various ways to get the CAI to call a routine in

> > the
> >> >> wb
> >> >> to run close code 'only' if Excel and hence the file is about to
> >> >> close.

> > I
> >> >> believe Chip Pearson has made available on his site a CAI to do that,
> >> >> which
> >> >> makes use of the 'hidden namespace'. I have a CAI that does similar
> >> >> but
> >> >> with
> >> >> a different approach (doesn't use the namespace) if interested.
> >> >>
> >> >> Regards,
> >> >> Peter T
> >> >>
> >> >> "TomThumb" <(E-Mail Removed)> wrote in message
> >> >> news:65374B59-7DE8-4DC4-BAC8-(E-Mail Removed)...
> >> >> > That is all I need to know: Just how can I obtain what is probably
> >> >> > a
> >> >> boolean
> >> >> > value telling me the user canceled a close.
> >> >> > --
> >> >> > TomThumb
> >> >>
> >> >>
> >> >>
> >>

> >
> >

>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      21st Sep 2007
Hi again,

> I thought it was the situation where the toolbar is created
> at workbook open and deleted at close.


I assumed same, turned out to be toolbar in an addin.

> Then why is the user being prompted to save changes?


Occurs if user attempts to close Excel while there are any unsaved workbooks
open. Concerning addins, in previous testing I found the Auto_close routine
always fires before user get the save changes prompt, but inconsistently
(not sure why) the BeforeClose event may fire either before or after user
gets the save changes prompt. The Toolbar will get deleted if called in the
auto_close and may get deleted if called in BeforeClose. The deactivate
event is not triggered in the addin.

Regards,
Peter T

"Doug Glancy" <(E-Mail Removed)> wrote in message
news:OFyx3rF$(E-Mail Removed)...
> Peter T,
>
> Then why is the user being prompted to save changes? I thought it was the
> situation where the toolbar is created at workbook open and deleted at
> close.
>
> Doug
>
> "Peter T" <peter_t@discussions> wrote in message
> news:e7Q5pVC$(E-Mail Removed)...
> > Hi Doug,
> >
> > The Deactivate & Activate events are not triggered in an addin, which as

I
> > understand is what the OP wants to cater for.
> >
> > Regards,
> > Peter T
> >
> > "Doug Glancy" <(E-Mail Removed)> wrote in message
> > news:#TUK4NB$(E-Mail Removed)...
> >> TomThumb,
> >>
> >> Instead of the Open and BeforeClose events, look at using Activate and
> >> Deactivate instead. When a workbook closes the Deactivate event fires

> > after
> >> the BeforeClose and the Cancel message. Also, then your toolbar will

be
> >> deleted when you switch to another workbook, which I'm guessing is also

> > what
> >> you want.
> >>
> >> hth,
> >>
> >> Doug
> >>
> >> "TomThumb" <(E-Mail Removed)> wrote in message
> >> news:7F367FEF-77C8-4D7F-9E78-(E-Mail Removed)...
> >> > Peter T:
> >> >
> >> > Thank you for responding to my plea for help. I should have spelled
> >> > out
> >> > what I have in mind:
> >> >
> >> > I have an Add-In Toolbar that I delete in my WorkBookBeforeClose

event
> >> > procedure. But when the user closes and then clicks "Cancel" when
> >> > asked
> >> > to
> >> > Save, the Close is terminated and the toolbar is gone. I want to

> > restore
> >> > that toolbar, or not delete it in the first place.
> >> >
> >> > Can I somehow get a boolean from WorkbookBeforeSave?
> >> > --
> >> > TomThumb
> >> >
> >> >
> >> > "Peter T" wrote:
> >> >
> >> >> "user canceled a close" - do you mean if user cancels Excel-quit or
> >> >> merely
> >> >> while doing file-close, that might be relevant depending on your

> > ultimate
> >> >> objective. However in either case there is no direct method to

return
> >> >> your
> >> >> boolean if user cancelled close during the 'save unsaved file(s)

> > prompt'.
> >> >>
> >> >> I assume you want to know so as to determine whether or not to run
> >> >> your
> >> >> close event code. One workaround is to run the close event as

normal,
> > but
> >> >> also call a routine with the OnTime method to restore as-was. Eg

with
> > an
> >> >> addins, might want to remove all menus as normal in the close event

> > then
> >> >> put
> >> >> them back again a few seconds later if the workbook is still open.
> >> >>
> >> >> A different approach is to use a Com-addin. This has the advantage
> >> >> that
> >> >> its
> >> >> close event only fires when Excel really is about to quit and won't

be
> >> >> cancelled. There are various ways to get the CAI to call a routine

in
> > the
> >> >> wb
> >> >> to run close code 'only' if Excel and hence the file is about to
> >> >> close.

> > I
> >> >> believe Chip Pearson has made available on his site a CAI to do

that,
> >> >> which
> >> >> makes use of the 'hidden namespace'. I have a CAI that does similar
> >> >> but
> >> >> with
> >> >> a different approach (doesn't use the namespace) if interested.
> >> >>
> >> >> Regards,
> >> >> Peter T
> >> >>
> >> >> "TomThumb" <(E-Mail Removed)> wrote in message
> >> >> news:65374B59-7DE8-4DC4-BAC8-(E-Mail Removed)...
> >> >> > That is all I need to know: Just how can I obtain what is

probably
> >> >> > a
> >> >> boolean
> >> >> > value telling me the user canceled a close.
> >> >> > --
> >> >> > TomThumb
> >> >>
> >> >>
> >> >>
> >>

> >
> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to detect IE window close (X) action by user? =?Utf-8?B?S3VtYXIuQS5QLlA=?= Microsoft ASP .NET 5 17th Oct 2007 11:43 AM
Unhiding worksheets if Close is Canceled =?Utf-8?B?SnVzdEJyZWF0aGU=?= Microsoft Excel Programming 8 4th Apr 2007 09:26 PM
How can I detect a user has clicked the X to close the Browser Window tarun.kataria@gmail.com Microsoft ASP .NET 7 7th Apr 2006 05:27 AM
How to detect if user has close the browser? Lord2702 Microsoft ASP .NET 3 10th Oct 2004 07:20 AM
How to detect that user click on close button (x) =?Utf-8?B?VHJhbiBIb25nIFF1YW5n?= Microsoft Access VBA Modules 6 10th Aug 2004 05:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:54 PM.