0

I have to click on SAVE in Download Window shown attached. I want do it using VBA but not using sendkeys or mouseevent. I wish something smiliar this: VBA Internet Explorer Automation - How to Select "Open" When Downloading a File

See attached the windows that has the button and the properties from these windows (got using AutoIT) and a resume below:

Download Window: Download Window AutoIT Window Properties: AutoIT Window Properties 1

Window
Title: Windows Internet Explorer
Class: #32770
Position: 1672, 227
Size: 391, 287
Style: 0x96C80284
ExStyle: 0x00010101
Handle: 0x005002D6

Control
Class: Button
Instance: 1
ClassnameNN: Button1
Name:
Advanced (Class): [CLASS:Button; INSTANCE:1]
ID:
Text: &Open
Position: 10, 114
Size: 365, 40
ControlClick Coords: 302, 30
Style: 0x5000200F
ExStyle: 0x00000000
Handle: 0x0048073C

Visible Text
&Open
&Save
Save &as
Cancel

Community
  • 1
  • 1
Marcelo Gazzola
  • 907
  • 12
  • 28

1 Answers1

0

works perfectly with the code below:

Sub Download()
Dim o As IUIAutomation
Dim e As IUIAutomationElement
Set o = New CUIAutomation
h = ie.hwnd
h = FindWindow("#32770", 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.GetCurrentPattern(UIA_InvokePatternId)
InvokePattern.Invoke

End Sub

Marcelo Gazzola
  • 907
  • 12
  • 28