自动保存IE11的对话框(vba - IUIAutomation)错误指针无效

时间:2016-12-08 10:44:14

标签: excel excel-vba vba

我正在尝试使用IUIAutomation从IE11下载文件,但是我在@Set e = o.ElementFromHandle(ByVal Child)@点获得了Error invalid指针。我在UIAutomationClient上安装了dll和swich,在工作簿参考上安装了VB Extensebility 5.3。

Private Sub Download_complete_Click_Close()
Dim o As IUIAutomation
Dim e As IUIAutomationElement
Set o = New CUIAutomation
Dim h As LongPtr
Do
    hwnd = FindWindow("IEFrame", "ACSMAGAM - Internet Explorer") ' main window
    DoEvents
     Debug.Print Hex(hwnd)
    Sleep 200
Loop Until hwnd Or Now > timeout

Debug.Print Hex(hwnd)

  Child = FindWindowEx(hwnd, 0, "Frame Notification Bar", "") ' pop up
  Debug.Print Hex(Child)
 SetForegroundWindow (Child)

Set e = o.ElementFromHandle(ByVal Child) ' here comes the error
Dim iCnd As IUIAutomationCondition
Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "&Apri")

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

0 个答案:

没有答案