| vb.net开发中使用excel插件的代码 |
|
|
|
|
| 来源: 作者: 添加日期:2007-10-12 16:34:37 点击次数: |
|
Microsoft.Office.Core.CommandBar) toolBar.Visible = True Return toolBar Catch Return Nothing End Try End Function ’在工具栏上添加一个按钮 Private Function MakeANewButton()Function MakeANewButton(ByVal commandBar As Microsoft.Office.Core.CommandBar, ByVal caption As String, ByVal faceID As Integer, ByVal clickHandler As Microsoft.Office. Core._CommandBarButtonEvents_ClickEventHandler) As Microsoft.Office.Core.CommandBarButton Try Dim newButton As Microsoft.Office.Core.CommandBarButton newButton = CType(commandBar.Controls.Add(Microsoft.Office.Core.MsoControlType.msoControlButton), Microsoft.Office.Core.CommandBarButton) newButton.Caption = caption newButton.FaceId = faceID AddHandler newButton.Click, clickHandler Return newButton Catch ex As System.Exception Return Nothing End Try End Function ’点击工具条按钮时应该执行的程序 Public Sub pasteText_Click()Sub pasteText_Click(ByVal barButton As Microsoft.Office.Core.CommandBarButton, ByRef someBool As Boolean) Dim text As String = "" Dim data As System.Windows.Forms.IDataObject = System.Windows.Forms.Clipboard.GetDataObject() If data.GetDataPresent(System.Windows.Forms.DataFormats.Text) Then text = data.GetData(System.Windows.Forms.DataFormats.Text).ToString() If (Not app Is Nothing) Then Me.app.ActiveCell.Value = text End If End If End Sub End Class
这样程序就完成了,赶紧动手体验吧!
|
|
| |