Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default commandbars in add-in

Hi
I have created an add-in and want to disable (not remove) my custom menu
when all wbooks are closed and only the add-in is left open. The menus are
removedwhen the add-in is closed.

The following code seemed to work ok at first then errored with 'Invalid
Procedure call' I would appreciate any advice as to where I am going wrong.

T.I.A.

Geoff

I have put this code in a class CAppEvents

Dim WithEvents oApp As Application
Private Sub Class_Initialize()
Set oApp = Application
End Sub

Private Sub oApp_WorkbookDeactivate(ByVal Wb As Workbook)
If Not Workbooks.Count 1 Then
Set popupbar = Application.CommandBars.ActiveMenuBar.Controls
_("CustomTools") ''''''Fails here
popupbar.Controls(1).Enabled = False
popupbar.Controls(2).Enabled = False
End If
End Sub

Private Sub oApp_WorkbookActivate(ByVal Wb As Workbook)
Set popupbar = Application.CommandBars.ActiveMenuBar.Controls("Cu stom Tools")
popupbar.Controls(1).Enabled = True
popupbar.Controls(2).Enabled = True
End Sub
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
CommandBars vs CommandBars(1).Controls Sean Excel Programming 3 April 3rd 06 01:34 PM
help --- Commandbars wAyne Excel Programming 5 February 17th 06 08:17 PM
Commandbars PosseJohn Excel Programming 1 December 16th 05 05:51 PM
CommandBars garry Excel Programming 3 June 24th 04 03:12 PM
CommandBars defj Excel Programming 2 November 16th 03 12:57 AM


All times are GMT +1. The time now is 12:07 AM.

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"