About menu bars and so...

Wil Moosa

Well-known Member
Joined
Aug 11, 2002
Messages
893
I have removed all menu bars from my project... and created a floating menu bar instead.

When I click this floating menu bar and push it against the upper, colored Excel bar (Microsoft Excel - Name of file.xls - X) a nice, integrated menu bar will be formed.

Is there a way to force this integrated menu bar to be formed automatically instead of manually?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Sub Create_Menu()
Dim MyBar As CommandBar
Dim MyPopup As CommandBarPopup
Dim MyButton As CommandBarButton

Delete_Menu

Set MyBar = CommandBars.Add(Name:=" ", _
Position:=msoBarFloating, temporary:=True)

With MyBar
.Top = -15
.Left = 600
Set MyPopup = .Controls.Add(Type:=msoControlPopup)
With MyPopup
.Caption = "BUDGET PLANNER MENU"
.BeginGroup = True
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Budget Wizard"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "Naar_rooster"
End With
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Sorteren op functie"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
.BeginGroup = False
.OnAction = "Sorteren_Functie"
End With

Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Sorteren op Naam"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
.BeginGroup = False
.OnAction = "Sorteren_Naam"
End With

Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Legenda"
.Style = msoButtonCaption
.BeginGroup = False
.OnAction = "Show_Legenda"
End With

Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Verklaring Afkortingen"
.Style = msoButtonCaption
.BeginGroup = False
.OnAction = "Show_Afkortingen"
End With

Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Help"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
.BeginGroup = False
.OnAction = "Naar_Help"
End With
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Afsluiten"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "Afsluiten"
End With
End With


.Width = 500
.Visible = True
End With

End Sub

Sub Delete_Menu()
On Error Resume Next
CommandBars("My Menu").Delete
On Error GoTo 0
End Sub
 
Upvote 0
The following adjusted code did it....

Sub Create_Menu()
Dim MyBar As CommandBar
Dim MyPopup As CommandBarPopup
Dim MyButton As CommandBarButton

Delete_Menu

Set MyBar = CommandBars.Add(Name:=" ", _
Position:=msoBarTop, temporary:=True)
Rem Position:=DmsoBarTop, temporary:=True)
Rem Position:=msoBarFloating, temporary:=True)

With MyBar
.Top = -15
.Left = 600
Set MyPopup = .Controls.Add(Type:=msoControlPopup)
With MyPopup
.Caption = "BUDGET PLANNER MENU"
.BeginGroup = True
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Budget Wizard"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "Naar_BudgetWizard"
End With
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Budget berekening"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "Naar_salarisgegevens"
End With

Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Overzicht O.R.T."
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
.BeginGroup = False
.OnAction = "ORT_Overzicht"
End With

Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Legenda"
.Style = msoButtonCaption
.BeginGroup = False
.OnAction = "Show_Legenda"
End With

Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Verklaring Afkortingen"
.Style = msoButtonCaption
.BeginGroup = False
.OnAction = "Show_Afkortingen"
End With

Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Help"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
.BeginGroup = False
.OnAction = "Naar_Help"
End With
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Afsluiten"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "Afsluiten"
End With
End With


Rem .Width = 500
.Visible = True
End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,002
Messages
6,122,652
Members
449,092
Latest member
peppernaut

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