版主能不能说再明白点。 我做了一个,可以还是要个标准模块
Private Sub BuildMenu()
Dim c As CommandBarButton
Dim cBar As CommandBar
On Error Resume Next
Set cBar = CommandBars(Me.Name & "右键菜单")
cBar.Delete
On Error GoTo 0
Set cBar = CommandBars.Add(Me.Name & "右键菜单", msoBarPopup)
Set c = cBar.Controls.Add(msoControlButton)
c.Caption = "代码建的右菜单,并调用窗体的菜单1"
c.OnAction = "=myPOP(1)"
c.Style = msoButtonCaption
Set c = cBar.Controls.Add(msoControlButton)
c.Caption = "菜单2"
c.OnAction = "=myPOP(2)"
c.Style = msoButtonCaption