pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875
Hi,
I need help with vba to create custom menu tab next to Addin tab, is this possible? If so please help.
Thanks alot.
The below code is cool enough however it comes under "addin Tab" i want new tab with name "myTab"
Code:
[/FONT]
[FONT=Courier New]Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next 'in case the menu item has already been deleted
Application.CommandBars("Worksheet Menu Bar").Controls("My Macros").Delete 'delete the menu item
End Sub
Private Sub Workbook_Open()
Dim cmbBar As CommandBar
Dim cmbControl As CommandBarControl
Set cmbBar = Application.CommandBars("Worksheet Menu Bar")
Set cmbControl = cmbBar.Controls.Add(Type:=msoControlPopup, temporary:=True) 'adds a menu item to the Menu Bar
With cmbControl
.Caption = "&My Macros" 'names the menu item
With .Controls.Add(Type:=msoControlButton) 'adds a dropdown button to the menu item
.Caption = "My Macro No 1" 'adds a description to the menu item
.OnAction = "RunMyMacro1" 'runs the specified macro
.FaceId = 1098 'assigns an icon to the dropdown
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "My Macro No 2"
.OnAction = "RunMyMacro2"
.FaceId = 108
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "My Macro No 3"
.OnAction = "RunMyMacro3"
.FaceId = 21
End With
End With
End Sub