【问题标题】:Word Automation and the Running Object TableWord 自动化和运行对象表
【发布时间】:2009-09-28 19:00:01
【问题描述】:

我正在使用 ROT 来查找任何活动的 MSWord 实例。在某些版本的 word 中,该文档没有在表格中注册,而是注册为 NORMAL 模板,因此我无法按照 microsoft 记录的标题找到该文档。有谁知道这个的修补程序?

【问题讨论】:

    标签: com automation ms-word


    【解决方案1】:

    FindWindowPartial API 对您有用吗?它将允许您搜索标题中带有 Microsoft Word 的窗口。

    Option Explicit
    
    Private Const GW_HWNDNEXT = 2
    Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    
    Function FindWindowPartial(ByVal Title As String) As String
        Dim hWndThis As Long
    
        hWndThis = FindWindow(vbNullString, vbNullString)
        While hWndThis
            Dim sTitle As String, sClass As String
            sTitle = Space$(255)
            sTitle = Left$(sTitle, GetWindowText(hWndThis, sTitle, Len(sTitle)))
            If InStr(sTitle, Title) > 0 Then
                FindWindowPartial = sTitle & "|" & FindWindowPartial
            End If
            hWndThis = GetWindow(hWndThis, GW_HWNDNEXT)
        Wend
    End Function
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-15
      • 1970-01-01
      • 2010-09-10
      • 1970-01-01
      • 2022-11-10
      • 2023-03-20
      • 2010-09-22
      相关资源
      最近更新 更多