Excel 2013 menubar incompatibility?

Joined
Jul 24, 2014
Messages
2
Reaction score
0
In Excel 2007/2010, the code below adds a "Simulation" submenu under the Add-Ins slot in the menubar for the workbook containing this code, and for all already-open workbooks. (This is the desired behavior,) In Excel 2013, the submenu doesn't appear in already-open workbooks. However, once the workbook containing this code is open, all subsequently-opened workbooks have the new menu entry. (So the user needs to save and reopen all already-open workbooks in order to move forward.)

How might I make 2013 behave like 2010 and 2007?

Sub Auto_Open()
If Not (Application.CommandBars.FindControl(Type:=msoControlPopup, Tag:="Simulation") Is Nothing) Then Exit Sub
With Application.CommandBars("Worksheet Menu Bar").Controls.Add(Type:=msoControlPopup, before:=10, temporary:=True)
.Caption = "Simulation"
.Tag = "Simulation"
With .Controls.Add(Type:=msoControlButton)
.Caption = "Run"
.OnAction = "Simulation_Run"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Continue"
.OnAction = "Simulation_Continue"
End With
End With
End Sub
 
Solved in an ugly fashion:

I used a For ... Next loop through all open windows, checking each ribbon separately for the added menu item, and adding it wherever it's not found.
 
Back
Top