【发布时间】:2015-12-22 14:15:13
【问题描述】:
我一直在尝试完全使用下面链接中给出的代码,但我无法让它与 IE 11 一起使用。
Automate saveas dialouge for IE9 (vba)
为了方便复制代码:
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
按钮未找到,执行后的意思
Set Button = e.FindFirst(TreeScope_Subtree, iCnd)
按钮仍然是“无”。 IE11 在这方面与 IE9 有什么不同吗?我应该将“PropertyCondition”更改为其他内容还是我在这里做错了什么?谢谢。
【问题讨论】:
-
您在这方面取得了进展吗?我正在尝试使用 Internet Explorer 自动下载
PDF文件。 -
遗憾的是没有。我尝试使用不同的条件迭代所有元素,但都是徒劳的。最终我使用了 SendKeys。这不是一个可靠的解决方案,但我不得不接受。
标签: excel vba internet-explorer-11