周一至周五 : 08:30 - 17:30 客服专员电话/微信:17301649370 QQ:2902102332
微信咨询

扫码微信咨询

关注公众号

关注微信公众号

电话: 021 5161 9370
返回顶部
VBA使用工具栏自定义按钮打开Word
显示全部楼层 倒序浏览 发表日期 2025-12-12 11:07:45 5次阅读 0次回复
本帖最后由 hong90342 于 2025-12-12 11:09 编辑

VBA使用工具栏自定义按钮打开Word

版本:企业版V9.89


  1. Imports SpreadsheetGear
  2. Imports KbInterfaces
  3. Imports System.Windows.Resources
  4. Imports System.Windows.Threading
  5. Imports System.Windows
  6. Imports System.Windows.Controls
  7. Imports C1.Silverlight
  8. Imports C1.Silverlight.C1MessageBoxButton
  9. Imports C1.Silverlight.C1MessageBoxIcon
  10. Imports Newtonsoft.Json
  11. Imports Newtonsoft.Json.Linq
  12. Imports System.IO
  13. Imports System.Text
  14. Imports System.Runtime.InteropServices.Automation
  15. Namespace ExcelViewVBDotnet
  16.         Public Class StandardInterface


  17.                 Dim btnName As String = ""
  18.                 Dim CF As TextBox, VW As Object
  19.                 Dim TS As StackPanel
  20.                 Dim EV As SpreadsheetGear.Windows.Controls.WorkbookView, AW As SpreadsheetGear.IWorkbook, Range As SpreadsheetGear.IRange
  21.                 Public Sub Workbook_Open(OldRoot As Object, NewRoot As Object, Excel As SpreadsheetGear.Windows.Controls.WorkbookView)
  22.                         EV = Excel
  23.                         Excel.GetLock()
  24.                         AW = Excel.ActiveWorkbook
  25.                         Range = AW.ActiveWorksheet.Range
  26.                         Excel.ReleaseLock()


  27.                         Dim click As Action(Of String) = Function(other)
  28.                         Call InsertTableRows()
  29.                         End Function
  30.                         App.KBAddButton(17, "msg", "生成", click)
  31. '-----------------------------------------------------------------------------------------------------------------------------
  32.                 End Sub'打开时执行事件

  33.                 Public Sub RangeSelection(sender As Object, e As SpreadsheetGear.Windows.Controls.RangeSelectionChangedEventArgs)

  34.                 End Sub'单元格选择后执行的事件

  35.                 Public Sub RangeChanged(sender As Object, e As SpreadsheetGear.Windows.Controls.RangeChangedEventArgs)

  36.                 End Sub'单元格编辑完成后执行事件

  37.                 Public Sub ButtunClick(sender As Object, e As SpreadsheetGear.Windows.Controls.ShapeActionEventArgs)

  38.                 End Sub'按钮/标签点击事件

  39.                 Public Sub FollowHyperlink(sender As Object)

  40.                 End Sub '暂不支持


  41.                 Sub InsertTableRows()
  42.                         Dim _word As Object = AutomationFactory.CreateObject("Word.Application")
  43.                         _word.visible = True
  44.                         _word.Documents.open("d:\word\demo.docx")'ActiveDocument
  45.                         ActiveWorkbook.WorkbookSet.GetLock()
复制代码


QQ2627049059
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则  允许回帖邮件提醒楼主

快表软件是国内较早研究表格类软件开发平台的团队之一,迄今已有十多年的行业经验.致力于为企事业单位提供实用可靠的数字化平台。
  • 微信公众号

  • 微信小商店

  • 微信客服

  • Powered by Discuz! X3.4 | Copyright © 2022-2024, XiRong Soft. | 快表软件
  • 沪ICP备13033196号 | 营业执照 |上海西戎软件科技有限公司|沪公网安备31011502002146号|沪ICP备13033196号 |