ram*_*592 9 internet-explorer automation vba
我想从网站下载excel表.到目前为止,我已经实现了自动点击下载按钮(网页抓取).现在ie9正在弹出一个保存为屏幕.我如何自动化?
Lif*_*sun 11
您可以试试这个,因为它在IE9上为我工作:

C:\Windows\System32\UIAutomationCore.dll文件复制到用户文档,即C:\Users\admin\Documents然后添加对UIAutomationClient宏文件的引用.粘贴到模块中的代码下方:
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
Run Code Online (Sandbox Code Playgroud)试试你的最后.