![]() |
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 |
All times are GMT +1. The time now is 04:45 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com