自动另存为的台词IE9(VBA) [英] Automate saveas dialouge for IE9 (vba)

查看:693
本文介绍了自动另存为的台词IE9(VBA)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从网站下载一个Excel工作表。我迄今直到点击下载按钮自动(网页抓取)来实现的。现在IE9是一坡平保存为屏幕。我如何自动完成这一点。将是真正的帮助。

I am trying to download an excel sheet from a website. I have thus far achieved untill clicking the download button automatically (web scraping) . now ie9 is poping a save as screen . how do i automate that. Would be of real help .

推荐答案

您,因为它是为我工作在IE9可以试试这个:

You may try this as it is worked for me on IE9:


  1. 复制文件 C:\\ WINDOWS \\ SYSTEM32 \\ UIAutomationCore.dll 文件到用户的文档即 C:\\用户\\ ADMIN \\文件然后添加引用 UIAutomationClient 来您的宏文件。

  2. 粘贴下面code模块中:

  1. Copy file C:\Windows\System32\UIAutomationCore.dll file to users Documents i.e C:\Users\admin\Documents then add reference UIAutomationClient to your macro file.
  2. Paste below code in your module:

    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   


试着在你结束。

这篇关于自动另存为的台词IE9(VBA)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆