|
-
Feb 1st, 2017, 08:29 PM
#1
Thread Starter
New Member
IE Automation - Getting Window Handles
Hello Experts,
I've had some recent success automating IE with VBA. I've been able to login to Crystal Reports, fill in some form information, and submit a request for a report. Once the report is generated, Crystal Reports gives you the option to export the report to pdf, rtf, etc. formats. This is where my problem starts. When I click the Export button, it creates a new dialog. From what I've read, I should be able to get the handle of this new dialog window, via FindWindow, FindWindowEx, and use SendMessage to send commands to the new dialog.
This is the code I have so far:
Code:
Dim lhWndC As Long
Dim lhWndP As Long
Dim sStr As String
' Get the handle of the parent window.
lhWndP = FindWindow(vbNullString, vbNullString) 'PARENT WINDOW
If (lhWndP <> 0) Then
' Cycle through all the child windows.
Do While lhWndP <> 0
sStr = String(GetWindowTextLength(lhWndP) + 1, Chr$(0))
GetWindowText lhWndP, sStr, Len(sStr)
sStr = Left$(sStr, Len(sStr) - 1)
' Once we find the child window with the title we're looking for...
If InStr(1, sStr, "Export Report") > 0 Then
' Get the handle of the Export Report window.
lhWndC = FindWindowEx(lhWndP, ByVal 0&, "BrowserFrameGripperClass", vbNullString)
If (lhWndC <> 0) Then
' Put the Export Report window to the foreground.
lngRet = SetForegroundWindow(lhWndC)
SendMessage lhWndC , BM_CLICK, 0, vbNullString
Else
MsgBox "Handle of OK button not found."
End If
Else
MsgBox "Handle of Export Report window not found."
End If
End If
lhWndP = GetWindow(lhWndP, GW_HWNDNEXT)
Loop
Else
MsgBox "Handle of parent window not found."
End If
Here is a screenshot of what uuSpy tells me:

Here is a screenshot of the Export Report dialog:

I'm actually trying to pick one of the choices from the drop down list. But I can't tell from uuSpy how to access that object. I don't have access to Spy++ as I do not have Visual Studio. Any thoughts on how to better communicate with this Export Report dialog would be greatly appreciated.
TMMc
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|