网站首页

家园论坛

老版论坛

家园博客

业界新闻

技术文档

下载中心

速查中心

图片中心

硬件资讯
上一篇:.NET组件和COM组件之间的相互操作 下一篇:ASP.NET 2.0中CSS失效解决方案
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 


  这样程序就完成了,赶紧动手体验吧!

本新闻共2页,当前在第2页  1  2  

 
设为首页 | 加入收藏 | 业务办理 | 友情链接 | 论坛版面 | 浙ICP备07502118号 |