I think I have an idea on what the issue is - If someone could verify - Much Appreciated as I dont want to break anything by changing stuff that I'm not sure on.
I have created quite a bit of code for a Project using the default Work Book Name of "ThisWorkbook"
The issue I am am seeing is that when I have both a Project Workbook open and a completely separate External Workbook open - I am seeing my Project code show up in the non related External Workbook.
This is the code in question :
When I have both a Project Workbook open and an External Wookbook open - I am seeing the Custom Menu (code above) show up in the External Workbook also.
I suspect that I either need to (either now OR should have done in the beginning of the project) Change the Default Name in Workbook Properties to something unique.
If you can verify that this is correct - would you know whether or not I will break things by changing it now.
Many thanks for any/all suggestions on this.
I have created quite a bit of code for a Project using the default Work Book Name of "ThisWorkbook"
The issue I am am seeing is that when I have both a Project Workbook open and a completely separate External Workbook open - I am seeing my Project code show up in the non related External Workbook.
This is the code in question :
Code:
Private Sub Workbook_Open()
Dim mymenubar As CommandBar
Dim newmenu As CommandBarPopup
Dim ctrl1, ctrl2, ctrl3, ctrl4, ctrl5 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
' Main Menu Options______________________________________________________________________________________________
Set ctrl1 = newmenu.Controls.Add(Type:=msoControlButton, ID:=1)
With ctrl1
.caption = "Save This Set As...."
.Style = msoButtonCaption
.OnAction = "'" & ThisWorkbook.Name & "'!saveas"
End With
Set ctrl2 = newmenu.Controls.Add(Type:=msoControlButton, ID:=1)
With ctrl2
.caption = "Print Set - All Values"
.Style = msoButtonCaption
.OnAction = "'" & ThisWorkbook.Name & "'!printall"
End With
Set ctrl3 = newmenu.Controls.Add(Type:=msoControlButton, ID:=1)
With ctrl3
.caption = "Print Set - No Cost"
.Style = msoButtonCaption
.OnAction = "'" & ThisWorkbook.Name & "'!printnocost"
End With
Set ctrl4 = newmenu.Controls.Add(Type:=msoControlButton, ID:=1)
With ctrl4
.caption = "Import - Update Price Guide"
.Style = msoButtonCaption
.OnAction = "'" & ThisWorkbook.Name & "'!importprice"
End With
Set ctrl5 = newmenu.Controls.Add(Type:=msoControlButton, ID:=1)
With ctrl5
.caption = "Import - Update Setbilder Version"
.Style = msoButtonCaption
.OnAction = "'" & ThisWorkbook.Name & "'!importset"
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
When I have both a Project Workbook open and an External Wookbook open - I am seeing the Custom Menu (code above) show up in the External Workbook also.
I suspect that I either need to (either now OR should have done in the beginning of the project) Change the Default Name in Workbook Properties to something unique.
If you can verify that this is correct - would you know whether or not I will break things by changing it now.
Many thanks for any/all suggestions on this.