msdn Q258511
HOWTO: Obtain the Window Handle for an Office Automation Server
----
Find the Window Handle for an Application That Is Single Instance code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim PptApp As Object
Set PptApp = CreateObject("PowerPoint.Application")
PptApp.Visible = True
Dim hWndPpt As Long
hWndPpt = FindWindow("PP9FrameClass", 0) 'PP97FrameClass w/ PowerPoint 97
MsgBox "hWndPpt ( " & Hex(hWndPpt) & " ) contains the Window Handle " & _
"of the PowerPoint application created by this program." & vbCr & _
"You can use this Window Handle in various Win 32 APIs, such " & _
"as SetForeGroundWindow," & vbCr & _
"which require a Window Handle parameter to be supplied." & vbCr & _
vbCr & "All Done. Click OK to close PowerPoint.", vbMsgBoxSetForeground
PptApp.Quit
Set PptApp = Nothing
End Sub
Find the Window Handle for an Application That Can Have Multiple Instances code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Caption = "New Caption Supplied by Program"
Dim hWndXl As Long
hWndXl = FindWindow("XLMAIN", xlApp.Caption)
xlApp.Caption = Empty 'Set the original caption back
xlApp.Visible = True
MsgBox "hWndXl ( " & Hex(hWndXl) & " ) contains the Window Handle " & _
"of the Excel application created by this program." & vbCr & _
"You can use this Window Handle in various Win 32 APIs, " & _
"such as SetForeGroundWindow," & vbCr & _
"which require a Window Handle parameter to be supplied." & vbCr _
& vbCr & "All Done. Click OK to close Excel.", vbMsgBoxSetForeground
xlApp.Quit
Set xlApp = Nothing
End Sub
PS. Если приложение Access, тогда можно проще Application.hWndAccessApp - родительское окно и Form[Report].hWnd