From my vb app how would I get a handle to an **open** word document and set focus to it??
Printable View
From my vb app how would I get a handle to an **open** word document and set focus to it??
Try this. Note: This will work if the document is open, but NOT minimized, but rather, running in the background. Also, you must know what the caption of the document is.VB Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long Private Sub Command1_Click() Dim WinWnd As Long Dim ShowWin As Long WinWnd = FindWindow(vbNullString, "Employee Appraisal Form.doc - Microsoft Word") If WinWnd = 0 Then MsgBox "Document not found" Else ShowWin = SetForegroundWindow(WinWnd) End If End Sub