| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 4875 人关注过本帖
标题:封装右键菜单没有反应,求指点
只看楼主 加入收藏
cunfu2010
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2017-4-6
收藏
 问题点数:0 回复次数:0 
封装右键菜单没有反应,求指点
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 Office.CommandBarControl
    Dim btNew As Office.CommandBarButton
    On Error Resume Next
    xlApp.CommandBars("cell").Reset
    Set cbBar = xlApp.CommandBars("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
2022-03-31 11:11
快速回复:封装右键菜单没有反应,求指点
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035759 second(s), 8 queries.
Copyright©2004-2025, BC-CN.NET, All Rights Reserved