VBA Internet Explorer Automation - 如何选择“打开”下载文件时 [英] VBA Internet Explorer Automation - How to Select "Open" When Downloading a File

查看:237
本文介绍了VBA Internet Explorer Automation - 如何选择“打开”下载文件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在stackoverflow上的第一个问题!

This is my first question ever here on stackoverflow!

我一直在寻找解决这个问题的一段时间,没有找到任何帮助。我可能只是在搜索中使用错误的关键字,但到目前为止我没有运气。这是一个问题:

I've been searching for a solution to this problem for a while and haven't found any help. I may just be using the wrong keywords in my searches, but so far I've had no luck. Here's the question:

在VBA中,如何从Internet Explorer中的文件下载对话框中选择打开选项?

只是为了额外的澄清,我正在谈论的是在下载文件时IE9中​​屏幕底部弹出的黄橙色条。

Just for extra clarification, I'm talking about the yellow-orange bar that pops up across the bottom of the screen in IE9 when a file is downloaded.

我正在做一些VBA自动化,使用Internet Explorer从网上下载数百个PDF,但是有一个中间步骤,在我获得实际的PDF之前,必须打开一个.fdf文件。所以我首先需要选择打开选项,以便我可以进入自动化的下一步。如前所述,我做了很多的搜索,迄今为止没有运气。

I'm doing some VBA automation to download hundreds of PDFs from the web using Internet Explorer, but there is an intermediate step where a .fdf file has to be opened before I get to the actual PDF. So I first need to select the "Open" option so that I can move on to the next step of the automation. Like I said earlier, I've done a lot of searching and had no luck so far.

我试过使用 SendKeys 希望击中 Enter 可以正常工作,这是最后一次没有工作的挣扎。

I've tried using SendKeys in hopes that hitting Enter would work, and that was a last ditch effort that didn't work.

提前感谢为了帮助!

推荐答案

我已经在这里广泛介绍了。

I have covered this extensively here.

主题 VBA / VB.Net / VB6-点击打开/保存/取消按钮在IE下载窗口 - 第一部分

链接 http://www.siddharthrout.com/2011/10/23/vbavb-netvb6click-opensavecancel-button-on-ie-download -window /

编辑(IMP)如果您正在使用IE 9请勿忘记阅读第2部分,因为它包含并涵盖IE 9下载​​窗口的窗口结构

主题 VBA / VB.Net / VB6点击打开/保存/取消按钮在IE下载窗口 - 第二部分

链接 http://www.siddharthrout.com/2012/02/02/vbavb -netvb6click-opensavecancel-button-on-ie-download-window-part-ii /

上述链接讨论如何使用API实现你想要的。

The above links discuss on how to use use the API's to achieve what you want.

从第一个链接...


喜欢你和我,我们都有名字,同样的窗口有句柄(hWnd),类等。一旦你知道这个hWnd是什么,它更容易与该窗口进行交互。

Like you and me, we both have names, similarly windows have "handles" (hWnd), Class etc. Once you know what that hWnd is, it is easier to interact with that window.

Findwindow API在这种情况下通过使用类名和窗口的标题(文件下载)来查找特定窗口的hWnd。 打开,保存和取消按钮本身是窗口,但它们是主窗口的窗口,即文件下载。这意味着每一个都将有一个hWnd :)要查找子窗口,我们不使用FindWindow,但使用FindWindowEx。所有三个按钮打开,保存和取消都具有与按钮相同的类。

Findwindow API finds the hWnd of a particular window by using the class name and the caption of the window ("File Download") in this case. The "Open", "Save" and "Cancel" buttons are windows in itself but they are child windows of the main window which is "File Download". That means each one of those will also have a hWnd :) To find the child windows, we don’t use FindWindow but use FindWindowEx. All the three buttons "Open", "Save" and "Cancel" have the same class which is " Button".

这篇关于VBA Internet Explorer Automation - 如何选择“打开”下载文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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