Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default App_WorkbookBeforeClose

I am using application level events to watch when workbooks close.

Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
Dim c As Object
For Each c In Application.CommandBars("worksheet Menu bar").Controls
If c.Caption = "Finops" Then
If App.Workbooks.Count = 1 Then
'''''If Workbooks("Genesis.xla").Name < "Genesis.xla" Then
Application.CommandBars("WorkSheet Menu
Bar").Controls("Finops").Visible = False
'''''End If
End If
End If
Next c
End Sub

The problem is this fires when an xla is unloaded as well. I need to test if
there is more then one workbook open in this method. If workbooks.count = 1
then I hide my menu. The problem is that the xla is not included in the
workbooks.count...
How can I best find out if the xla is the file that is closing? and skip the
hide line if so...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default App_WorkbookBeforeClose

Never mind. I found the answer...

Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
Dim c As Object
For Each c In Application.CommandBars("worksheet Menu bar").Controls
If c.Caption = "Finops" Then
If App.Workbooks.Count = 1 Then
If Right(ActiveWorkbook.Name, 3) < "xla" Then
Application.CommandBars("WorkSheet Menu
Bar").Controls("Finops").Visible = False
End If
End If
End If
Next c
End Sub

"Kent Prokopy" wrote:

I am using application level events to watch when workbooks close.

Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
Dim c As Object
For Each c In Application.CommandBars("worksheet Menu bar").Controls
If c.Caption = "Finops" Then
If App.Workbooks.Count = 1 Then
'''''If Workbooks("Genesis.xla").Name < "Genesis.xla" Then
Application.CommandBars("WorkSheet Menu
Bar").Controls("Finops").Visible = False
'''''End If
End If
End If
Next c
End Sub

The problem is this fires when an xla is unloaded as well. I need to test if
there is more then one workbook open in this method. If workbooks.count = 1
then I hide my menu. The problem is that the xla is not included in the
workbooks.count...
How can I best find out if the xla is the file that is closing? and skip the
hide line if so...

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
HELP with App_WorkbookBeforeClose!!! [email protected] Excel Programming 0 June 4th 07 11:35 PM
App_WorkBookBeforeClose() [email protected] Excel Programming 1 April 30th 07 12:00 PM


All times are GMT +1. The time now is 10:10 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"