Need help with vba to create custom menu.

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
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Thanks Andrew that is very helpful....


Okay, if we cant create a new tab by VBA can we create new area in Addin Tab next to Menu Commands group in addin tab?

Thanks again...
 
Upvote 0
Wow...:)!!! i think i'll spend days to understand that..but 'll try again...i got this link the other day i think from Brian but couldnt follow it very well...


If there's a straight code to achieve this things then it'd be great;)....

By Pedie!
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,789
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top