Put this code in a module. Run the menu with Alt+F8 and create_menu.
The code for the actual button must be placed in a public module (I think) in order to execute when you select an option on the floating menu bar.
Sub Create_Menu()
Dim MyBar As CommandBar
Dim MyButton As CommandBarButton
Delete_Menu
'name of your floating bar
Set MyBar = CommandBars.Add(Name:="Two Buttons", _
Position:=msoBarFloating, temporary:=True)
With MyBar
.Top = 50
.Left = 650
'the two buttons that you want
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Back to main"
.Style = msoButtonCaption
.BeginGroup = False
'here you refer to the code to execute when you select this option
'put code to execute in module (not a private one)
.OnAction = "Macro_to_go_to_main"
End With
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Back to top"
.Style = msoButtonCaption
.BeginGroup = False
.OnAction = "Macro_to_go_to_top"
End With
.Width = 150
.Visible = True
End With
End Sub
Sub Delete_Menu()
On Error Resume Next
'remove menu when active before activating again.
CommandBars("Two Buttons").Delete
On Error GoTo 0
End Sub
Charlize