2009-09-01 2 views
1

ROT를 사용하여 활성 MSWord 인스턴스를 찾습니다. Word의 일부 버전에서는 문서가 표에 등록되지 않고 대신 NORMAL 서식 파일로 등록되므로 Microsoft에서 문서화 한 제목으로 문서를 찾을 수 없습니다. 누구든지이 문제에 대한 핫픽스를 알고 있습니까?Word 자동화 및 실행 개체 테이블

답변

0

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 
관련 문제