html5中文学习网

您的位置: 首页 > 网络编程 > ASP.NET » 正文

从Excel 单元格定位到Word 文档中指定的位置带来的思考_.NET教程_编程技术

[ ] 已经帮助:人解决问题
excel|word|单元格

'以下VBA脚本实现标题阐述功能,考虑以下问题:
如何捕获一个Cell单元格的单击事件?Excel 中能否添加处理其他的Windows 消息?
'Unit   :   mcc
'Fun    :   Goto exactly position in Word from Excel impls by VBA.
'args   :   Bookmark string(predefined in Word handed yourself or using tools)
'ref    :   Ms Word/Excel object lib.
'modify :   1.open word archives in readonly way 2.get abs path using for anchor
'future :   1.search by string exactly
'Author :   qjwxsd
'DT     :   2005-04-18~~

Const TC3 = "TC03_体版管理/TC03_Software license management"
Const TC4 = "TC04_配源管理/TC04_Periphery resource"
Const TC10 = "TC10_料安全管理/TC10_Data security management"

Public Sub gotoWord(FileName, Bookmark As String)
    On Error Resume Next
    Dim a As Word.Application
    Dim b As Word.Document
   
    Dim c As Excel.Application
    Dim d As Excel.Workbook
    Dim e As Excel.Worksheet

    Dim path As String
   
    Set c = GetObject(, "Excel.Application")
    Set d = c.ActiveWorkbook
    Set e = d.ActiveSheet
    'path = c.path
    path = d.path
    '取得当前功能清单的路径,传到Word中。否则Word无法取得路径,
    '打开相应的TC。
    Set a = GetObject(, "Word.Application")
    If a = Null Then
        Set a = CreateObject("Word.Application")
    End If
   
    'a.Documents.Open "H:/0408/PCmain5.5.0 _Other.doc"
    'MsgBox a.Path
    'MsgBox Application.Path
    'MsgBox CurDir
    'MsgBox a.Documents.Item(0).FullName
   
    a.Documents.Open path & "/" & FileName & ".doc", ReadOnly:=True
    a.Selection.GoTo what:=wdGoToBookmark, Name:=Bookmark
    a.Visible = True
    a.Activate '前台显示Word窗体
End Sub

Private Sub Label1_Click()
    gotoWord TC3, "TC3_1"
End Sub

Private Sub Label10_Click()
    gotoWord TC4, "TC4_4"
End Sub

AQvHTML5中文学习网 - HTML5先行者学习网
AQvHTML5中文学习网 - HTML5先行者学习网
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助