注册 登录
编程论坛 Matlab

封装右键菜单没有反应,求指点

cunfu2010 发布于 2022-03-31 11:11, 3870 次点击
Option Explicit
Public xlApp As Excel.Application
Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
    Set xlApp = Application
    CreateToolbarButtons
End Sub
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
    Set xlApp = Nothing
End Sub

Public Sub CreateToolbarButtons()
    Dim cbBar As
    Dim btNew As
    On Error Resume Next
    ("cell").Reset
    Set cbBar = ("cell").Controls.Add(msoControlPopup, Before:=1)
    cbBar.Caption = "调试"
    Set btNew = cbBar.Controls.Add(1, 2)
    With btNew
        .Caption = "调试"
        .OnAction = "test1"
    End With
End Sub

Sub test1()
    MsgBox "你成功了!"
End Sub
0 回复
1