![]() |
macro only runs on fresh open of excel?
Hi Todd,
I see that you refer to "Worksheet MenuBar" and "Worksheet Menu Bar". Could that be the problem? -- Regards, Jake Marx MS MVP - Excel Todd wrote: I have a macro that only runs the first time you open excel. If I close the workbook and reopen it , it does not run (it is supposed to run everytime). I don't know what to think about that. I went to different computer station and it didn't run at all. Help? Todd The error is marked at: Set MenuItem = Application.CommandBars("Worksheet Menu Bar").Controls(11) Private Sub Workbook_Open() ProtectionMenuBar_Add End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) ProtectionMenuBar_Delete End Sub Sub ProtectionMenuBar_Add() Dim MenuItem As CommandBarControl ProtectionMenuBar_Delete Application.CommandBars("Worksheet MenuBar").Controls.Add Type:= _ msoControlButton, ID:=893, Befo=11 If MenuItem Is Nothing Then Exit Sub Set MenuItem = Nothing End Sub Sub ProtectionMenuBar_Delete() Dim MenuItem As CommandBarControl Set MenuItem = Application.CommandBars("Worksheet Menu Bar").Controls(11) If Not MenuItem Is Nothing Then MenuItem.Delete End If Set MenuItem = Nothing End Sub |
All times are GMT +1. The time now is 03:43 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com