Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 300
Default Detecting a cancel on Workbook_BeforeClose event?

Can I detect when a user selects cancel in a BeforeClose event? It appears
to me that the event has already been run when the user is asked if they
want to save, not save, or cancel. I don't see an AfterCancel event.

This as the BeforeClose is removing my Toolbar and I'd like to put it back
after a cancel.

Don <donwiss at panix.com.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Detecting a cancel on Workbook_BeforeClose event?

Don,

How about removing the toolbar in Workbook_Deactivate, and restore it in
Workbook_Activate as well as workbook_Open?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Don Wiss" wrote in message
...
Can I detect when a user selects cancel in a BeforeClose event? It appears
to me that the event has already been run when the user is asked if they
want to save, not save, or cancel. I don't see an AfterCancel event.

This as the BeforeClose is removing my Toolbar and I'd like to put it back
after a cancel.

Don <donwiss at panix.com.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 300
Default Detecting a cancel on Workbook_BeforeClose event?

On 17 Jan 2005, Bob Phillips wrote:

Don Wiss wrote:
Can I detect when a user selects cancel in a BeforeClose event? It appears
to me that the event has already been run when the user is asked if they
want to save, not save, or cancel. I don't see an AfterCancel event.

This as the BeforeClose is removing my Toolbar and I'd like to put it back
after a cancel.


How about removing the toolbar in Workbook_Deactivate, and restore it in
Workbook_Activate as well as workbook_Open?


If in a Workbook_Activate it wouldn't need to be in a Workbook_Open. I am
using this way now. The only downside is when flipping between workbooks
that use the toolbar the toolbar disappears and then reappears. I haven't
yet found a way around this.

This is the code I'm calling on the Workbook_Activate:

Sub RestoreToolbar()
' called by button on Main sheet and workbook activate

Application.ScreenUpdating = False
If DoesToolBarExist("CasFacToolbar") Then
Application.CommandBars("CasFacToolbar").Visible = True
Else
If DoesProjectExist("CFRTAddIn") Then
Application.Run "'CFRT Add-In.xla'!NewToolBar"
Else
Workbooks.Open ActiveWorkbook.path & "\CFRT Add-In.xla"
End If
End If

End Sub

Function DoesToolBarExist(ToolBarName As String) As Boolean
' addin name is case sensitive. is project name, not file name
Dim CB As Object
DoesToolBarExist = False
For Each CB In Application.CommandBars
If CB.Name = ToolBarName Then DoesToolBarExist = True
Next
End Function




Don <donwiss at panix.com.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Detecting a cancel on Workbook_BeforeClose event?


"Don Wiss" wrote in message
...
On 17 Jan 2005, Bob Phillips wrote:

Don Wiss wrote:
Can I detect when a user selects cancel in a BeforeClose event? It

appears
to me that the event has already been run when the user is asked if

they
want to save, not save, or cancel. I don't see an AfterCancel event.

This as the BeforeClose is removing my Toolbar and I'd like to put it

back
after a cancel.


How about removing the toolbar in Workbook_Deactivate, and restore it in
Workbook_Activate as well as workbook_Open?


If in a Workbook_Activate it wouldn't need to be in a Workbook_Open. I am
using this way now. The only downside is when flipping between workbooks
that use the toolbar the toolbar disappears and then reappears. I haven't
yet found a way around this.


If you knew all the workbooks that use the toolbar, you could use
Application events, initiated from Personal.xls.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Workbook_BeforeClose(Cancel As Boolean) - Cancel won't work gpmichal Setting up and Configuration of Excel 1 May 12th 09 02:33 AM
Detecting Cancel in an InputBox Method Connie Excel Discussion (Misc queries) 2 October 19th 06 01:32 PM
Workbook_Beforeclose vs BeforeClose Event Juan Pablo González Excel Programming 3 February 2nd 04 12:17 AM
Workbook_BeforeClose Event Shatin Excel Programming 2 January 24th 04 03:50 AM


All times are GMT +1. The time now is 01:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"