0
How to automate Internet Explorer through VBA ?
I tried to automate downloading of files on Internet Explorer through VBA but a popup having buttons OPEN and SAVE in IE11 is causing hindrance. I heard that using UI Automation, this problem can be tackled. I want to learn UI Automation but unable to get any good content on internet...Please suggest me any tutorial regarding UI Automation through VBA...
5 Respuestas
0
Option Explicit
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
Dim o As IUIAutomation
Dim e As IUIAutomationElement
Set o = New CUIAutomation
Dim h As LongPtr
h = ieApp.hWnd
h = FindWindowEx(h, 0, "Frame Notification Bar", vbNullString)
If h = 0 Then Exit Sub
Set e = o.ElementFromHandle(ByVal h)
Dim iCnd As IUIAutomationCondition
Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Save")
Dim Button As IUIAutomationElement
Set Button = e.FindFirst(TreeScope_Subtree, iCnd)
Dim InvokePattern As IUIAutomationInvokePattern
Set InvokePattern = Button.GetCurrentPatter
This is VBA code which i took from internet..
0
Yeah u need use findwindow, hWnd u can get in spy++
0
You can't rely on Spy++ to get a window handle. Window handle of the file dialog will be different everytime the dialog is created.
0
Ipang Can you please suggest me any tutorial online, where I can understand how to implement UI Automation...
0
Sorry bro, I learnt it long time ago, but now I only remember very slightly.