1

I have been trying to use exactly the code given in the link below but I cannot get it to work with IE 11.

Automate saveas dialouge for IE9 (vba)

Copying the code for convenience:

Option Explicit
Dim ie As InternetExplorer
Dim h As LongPtr
Private Declare PtrSafe Function FindWindowEx Lib "user32" _ 
  Alias "FindWindowExA" (ByVal hWnd1 As LongPtr, _
  ByVal hWnd2 As LongPtr, ByVal lpsz1 As String, _
  ByVal lpsz2 As String) As LongPtr

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

The button is not found, meaning after executing

Set Button = e.FindFirst(TreeScope_Subtree, iCnd)

Button is still 'nothing'. Is IE11 any different from IE9 in this respect? Should I change "PropertyCondition" to something else or am I doing something wrong here? Thank you.

Community
  • 1
  • 1
zaptask
  • 687
  • 1
  • 8
  • 18
  • Have you made any progress with this? I am trying to automate the downloading of `PDF` files using Internet Explorer. – CJ7 Mar 13 '16 at 06:08
  • Sadly not. I tried iterating over all elements, using different conditions but all in vain. Eventually I used SendKeys. It's not a solid solution but I had to settle for that. – zaptask Mar 14 '16 at 13:15

1 Answers1

1

Not sure if this solves your prob but maybe you are using IE in a installation language different from "EN-US". In this case you should replace

Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Save")

by the property name which you can take verbatim from the button, e.g. for "DE-DE"

Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Speichern")

That helped for me. However I find it disgusting ....

Maksim
  • 511
  • 5
  • 15