Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The code I have currently in an addin is below. What I am finding is that
sometimes Excel doesn't close properly or for any other reason the adding of these command bars becomes duplicated. I have had to remove up to twenty on some of my staffs computers. How can I write this so that it checks to see if the command bar exists and if it does to not add it again? Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Application.CommandBars("Worksheet Menu Bar"). _ Controls("Tools").Controls("Import DR Data File").Delete Application.CommandBars("Worksheet Menu Bar"). _ Controls("Tools").Controls("Daily Revenue Reset").Delete End Sub Private Sub Workbook_Open() Set newmenuitem = Application.CommandBars _ ("Worksheet Menu Bar").Controls("Tools").Controls.Add With newmenuitem .Caption = "Import DR Data File" .FaceId = 312 .BeginGroup = True .OnAction = "MorningReport" End With Set newmenuitem = Application.CommandBars _ ("Worksheet Menu Bar").Controls("Tools").Controls.Add With newmenuitem .Caption = "Daily Revenue Reset" .FaceId = 1678 .BeginGroup = False .OnAction = "reset_morning_reports" End With End Sub -- Thanks! Shane W |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
CommandBars & Custom | Excel Programming | |||
Bulk-Delete All Custom Commandbars | Excel Programming | |||
Prob: Custom CommandBars and .xls Files Being Re-Opened | Excel Programming | |||
Custom faces for custom menus/commandbars | Excel Programming | |||
Question on custom commandbars | Excel Programming |