I have an Add-ins Menu Bar (which works fine) defined and processed in "ThisWorkbook" using the code below:
The issue is that I need to have multiple copies of this workbook open at the same time.
To get multiple copies of the workbook I copy the original existing workbook save it as a different filename
So now 2 different workbooks with 2 different file names
When I open both workbooks - Each one shows the Add-ins menu but when I click on either Add-ins menu - I see duplicate Menus and duplicate CTRLs within those menus
If open 3 of the workbooks - I see 3 of the Menu items and 3 sets of CTRLs
Anyone please?
The issue is that I need to have multiple copies of this workbook open at the same time.
To get multiple copies of the workbook I copy the original existing workbook save it as a different filename
So now 2 different workbooks with 2 different file names
When I open both workbooks - Each one shows the Add-ins menu but when I click on either Add-ins menu - I see duplicate Menus and duplicate CTRLs within those menus
If open 3 of the workbooks - I see 3 of the Menu items and 3 sets of CTRLs
Anyone please?
Code:
Private Sub Workbook_Open()
Dim mymenubar As CommandBar
Dim newmenu As CommandBarPopup
Dim ctrl1, ctrl2 As CommandBarButton
Set mymenubar = Application.CommandBars("Worksheet menu Bar")
Set newmenu = mymenubar.Controls.Add(Type:=msoControlPopup, Temporary:=True, before:=2)
'newmenu.caption = "SetBilder-1955 Topps"
mymenubar.Visible = True
Set ctrl1 = newmenu.Controls.Add(Type:=msoControlButton, ID:=1)
With ctrl1
.caption = "Import Set"
.Style = msoButtonCaption
.OnAction = "'" & ThisWorkbook.Name & "'!importset"
End With
Set ctrl2 = newmenu.Controls.Add(Type:=msoControlButton, ID:=1)
With ctrl2
.caption = "Import Price Guide"
.Style = msoButtonCaption
.OnAction = "'" & ThisWorkbook.Name & "'!importprice"
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim CmdBar As CommandBar
Dim CmdBarMenu As CommandBarControl
On Error Resume Next
Set CmdBar = Application.CommandBars("Worksheet Menu Bar")
Set CmdBarMenu = CmdBar.Controls("SetBuilder")
CmdBarMenu.Delete
Set CmdBarMenu = CmdBar.Controls("SetBilder")
CmdBarMenu.Delete
End Sub