代码语言:javascript复制
Sub SetMenu()
Dim myBar As CommandBar
Dim myButton As CommandBarButton
Set myBar = CommandBars.Add(Name:="vb小源码", _
Position:=msoBarTop, _
MenuBar:=True)
Set myButton = myBar.Controls.Add(msoControlButton)
myButton.Style = msoButtonCaption
myButton.Caption = "退出[&E]"
myButton.OnAction = "ExitSYS"
Set myButton = myBar.Controls.Add(msoControlButton)
myButton.Style = msoButtonCaption
myButton.Caption = "返回[&R]"
myButton.OnAction = "ReturnMAIN"
myButton.Visible = True
myBar.Protection = msoBarNoMove msoBarNoCustomize
myBar.Visible = True
End Sub