Creating sub menu in Command bar
Not sure if someone will still see this old post... I tried for a while to
make this sample run and finaly I could but how do I delete it when closing
the file... each time a run the file it creates a new comandbar called "Name
of new bar" and I can not delete it... I got my command bar full of them....
I need to close all my excel files to get ride of it... any idea?
"Roman" wrote:
Hi Anders,
try this one:
Sub makemenewbar()
Set mynewbar = CommandBars(1).Controls.Add(Type:=msoControlPopup,
Temporary:=True)
With mynewbar
..Caption = "Name of new bar"
End With
Set button1 = mynewbar.Controls.Add(Type:=msoControlButton)
With button1
.Caption = "Button1"
.OnAction = "macro1"
End With
Set mysubmenu = mynewbar.Controls.Add(Type:=msoControlPopup)
With mysubmenu
.Caption = "Submenu1"
'.OnAction = "sheets_startuf"
End With
Set button2 = mysubmenu.Controls.Add(Type:=msoControlButton)
With button2
.Caption = "Button2 name"
.OnAction = "macro2"
End With
Set button3 = mysubmenu.Controls.Add(Type:=msoControlButton)
With button3
.Caption = "Button3 name"
.OnAction = "macro3"
End With
End Sub
|