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...

2nd Apr 2021, 5:25 PM
Sanjeev Kumar
Sanjeev Kumar - avatar
5 ответов
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..
2nd Apr 2021, 5:28 PM
Sanjeev Kumar
Sanjeev Kumar - avatar
0
Yeah u need use findwindow, hWnd u can get in spy++
2nd Apr 2021, 6:58 PM
Илья Мирошник
Илья Мирошник - avatar
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.
3rd Apr 2021, 2:28 AM
Ipang
0
Ipang Can you please suggest me any tutorial online, where I can understand how to implement UI Automation...
3rd Apr 2021, 3:09 AM
Sanjeev Kumar
Sanjeev Kumar - avatar
0
Sorry bro, I learnt it long time ago, but now I only remember very slightly.
3rd Apr 2021, 3:14 AM
Ipang