以下是引用片段:
Public Class ConnectClass Connect
Implements Extensibility.IDTExtensibility2
Dim app As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Dim addInInstance As Object
Dim pasteText As Microsoft.Office.Core.CommandBarButton ‘定义一个工具栏按钮
Public Sub OnBeginShutdown()Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
End Sub
Public Sub OnAddInsUpdate()Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub
Public Sub OnStartupComplete()Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete
End Sub
Public Sub OnDisconnection()Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array)
Implements Extensibility.IDTExtensibility2.OnDisconnection
End Sub
Public Sub OnConnection()Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode,
ByVal addInInst As Object, ByRef custom As System.Array)
Implements Extensibility.IDTExtensibility2.OnConnection
If TypeOf (application) Is Excel.Application Then app = CType(application, Excel.Application)
addInInstance = addInInst
wb = app.ActiveWorkbook
ws = CType(wb.ActiveSheet, Excel.Worksheet)
Dim toolbar As Microsoft.Office.Core.CommandBar = Nothing
If Not app Is Nothing Then
toolbar = AddToolbar(app, "专用工具栏") ’添加工具栏
End If
’ 建立按钮添加文本
pasteText = MakeANewButton(toolbar, "Insert text",
1044, AddressOf pasteText_Click) ’添加工具栏按钮并帮定事件
End Sub
’添加工具栏
Private Function AddToolbar()Function AddToolbar(ByVal ex As Excel.Application, _
ByVal toolbarName As String) As Microsoft.Office.Core.CommandBar
Dim toolBar As Microsoft.Office.Core.CommandBar = Nothing
Try
’ 为add-in建立一个命令条
toolBar = CType(ex.CommandBars.Add(toolbarName,
Microsoft.Office.Core.MsoBarPosition.msoBarTop, , True),
【vb.net开发中使用excel插件的代码】相关文章:
2025年外省高中学业水平合格性考试成绩转入江苏认定的通告公布05-09
Vb中控件的自动排列05-09
写未来的作文300字05-09
Our Mother Is the Same 我们的妈妈是一样的05-09
中国大地保险公司实习报告05-09
小学父爱的作文600字05-09
07年4月北师大“中国古代文学史(一)”串讲(5)05-09
汪涵讲述小时候成长经历:鸡毛掸子的故事05-09
2023年广东梅州中考成绩查询时间及查分入口[7月7日起]05-09
关于清明节的英语作文:清明节05-09
