Currenlty I'm using the following code to create a custom drop down menu to access my macros. What I'm wodering is there anywhere I can split up/edit the code so that I can put the relevant peices in there own XLA file they appy to?
Private Sub Workbook_Open()
Dim cMenu1 As CommandBarControl
Dim cbMainMenuBar As CommandBar
Dim iHelpMenu As Integer
Dim cbcCutomMenu As CommandBarControl
On Error GoTo 0
On Error Resume Next
'Exit Sub
'MsgBox "The PQA Macros are currently in a transistion phase." & Chr(13) & "Testing is not yet complete", vbInformation, "!! NOTICE !!"
'(1)Delete any existing one. We must use On Error Resume next _
in case it does not exist.
Application.CommandBars("Worksheet Menu Bar").Controls("&PQA Add-Ins").Delete
'(2)Set a CommandBar variable to Worksheet menu bar
Set cbMainMenuBar = _
Application.CommandBars("Worksheet Menu Bar")
'(3)Return the Index number of the Help menu. We can then use _
this to place a custom menu before.
iHelpMenu = _
cbMainMenuBar.Controls("Help").Index
'(4)Add a Control to the "Worksheet Menu Bar" before Help.
'Set a CommandBarControl variable to it
Set cbcCutomMenu = _
cbMainMenuBar.Controls.Add(Type:=msoControlPopup, _
Before:=iHelpMenu)
'(5)Give the control a caption
cbcCutomMenu.Caption = "&PQA Add-Ins"
'(6)Working with our new Control, add a sub control and _
give it a Caption and tell it which macro to run (OnAction).
'(6a)Add another sub control give it a Caption _
and tell it which macro to run (OnAction)
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Auto Filter"
.OnAction = "AutoFilter.AutoFilter_Run"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Buyers Report"
.OnAction = "Generate.Run"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "CITE"
.OnAction = "CITE.Cite_Load"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Duplicates Search"
.OnAction = "Duplicates.Duplicates_Run"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Import Return Notes"
.OnAction = "Import_Returns_Data.IRN_Run"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Multi Find"
.OnAction = "MassFind.Start"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Probality Scanner"
.OnAction = "Research.PV_Scan"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Product ID Lookup"
.OnAction = "GetPID.Run"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Product Review"
.OnAction = "Product_Review.Run"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "PVP Report Creator"
.OnAction = "PVP.PVP_Run"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Unfilter Report Integrity Check"
.OnAction = "UFRIC.Run"
End With
With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Settings"
.OnAction = "Brain_Settings.Brain_Run"
End With
'Repeat step "6a" for each menu item you want to add.
'Add another menu that will lead off to another menu
'Set a CommandBarControl variable to it
'Set cbcCutomMenu = cbcCutomMenu.Controls.Add(Type:=msoControlPopup)
' Give the control a caption
' cbcCutomMenu.Caption = "Ne&xt Menu"
'Add a contol to the sub menu, just created above
' With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
' .Caption = "&Charts"
' .FaceId = 420
' .OnAction = "MyMacro2"
' End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
'Removes the menu from the workbook when closing
Application.CommandBars("Worksheet Menu Bar").Controls("&PQA Add-Ins").Delete
On Error GoTo 0
End Sub
Bookmarks