扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:hhjjhjhj 来源:论坛 2007年10月14日
关键字:
Private Sub IDTExtensibility2_OnConnection(ByVal _ Application As Object, ByVal ConnectMode As _ AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst _ As Object, custom() As Variant) ' 存储启动引用 Set appHostApp = Application ' 添加命令条 Set cbbButton = CreateBar() End Sub |
Private Sub IDTExtensibility2_OnDisconnection(ByVal _ RemoveMode As AddInDesignerObjects.ext_DisconnectMode, _ custom() As Variant) RemoveToolbar ' 移除要关闭的引用 Set appHostApp = Nothing Set cbbButton = Nothing End Sub |
Public Function CreateBar() As Office.CommandBarButton ' 指定命令条 Dim cbcMyBar As Office.CommandBar Dim btnMyButton As Office.CommandBarButton On Error GoTo CreateBar_Err Set cbcMyBar = appHostApp.CommandBars.Add(Name:="GreetingBar") ' 指定命令条按钮 Set btnMyButton = cbcMyBar.Controls.Add(Type:=msoControlButton, _ Parameter:="Greetings") With btnMyButton .Style = msoButtonCaption .BeginGroup = True .Caption = "&Greetings" .TooltipText = "Display Hello World Message" .Width = "24" End With ' 显示并返回命令条 cbcMyBar.Visible = True Set CreateBar = btnMyButton Exit Function CreateBar_Err: MsgBox Err.Number & vbCrLf & Err.Description End Function |
Private Function RemoveToolbar() appHostApp.CommandBars("GreetingBar").Delete End Function |
Private Sub cbbButton_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean) MsgBox ("Hello World!") End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者