简体   繁体   English

VBA使用Internet Explorer 11自动下载文件

[英]VBA automate file download using Internet Explorer 11

I know this question has been answered many times for older versions of Internet Explorer, but I am having trouble finding an answer for IE 11. 我知道这个问题已经针对旧版本的Internet Explorer回答了很多次,但是我很难找到IE 11的答案。

I am trying to automate a file download from Internet Explorer 11. I have code to access the site, log in and generate the download request, but I am stuck on how to select "Save" when the download dialogue bar comes up (See image). 我正在尝试自动从Internet Explorer 11下载文件。我具有访问该站点,登录并生成下载请求的代码,但是当出现下载对话框栏时,我仍然选择如何选择“保存”(参见图片) )。

图片

I've read through this very good tutorial but it was done on IE 8/9. 我已经阅读了这个非常好的教程,但是它是在IE 8/9上完成的。 When I check for the "File Download" window it isn't found so maybe the handle (hWnd) has changed? 当我检查“文件下载”窗口时,找不到它,因此句柄(hWnd)可能已更改? I am not comfortable enough in other coding to get the hWnd for that element. 我对其他编码不太满意,无法获得该元素的hWnd。 http://www.siddharthrout.com/2011/10/23/vbavb-netvb6click-opensavecancel-button-on-ie-download-window/ http://www.siddharthrout.com/2011/10/23/vbavb-netvb6click-opensavecancel-button-on-ie-download-window/

I have a macro that download a file from Internet Explorer as well, I dont use your IE version but I may works 我也有一个宏,它也可以从Internet Explorer下载文件,我不使用您的IE版本,但是我可以使用

SendKeys "{F6}", True
SendKeys "{TAB}", True
SendKeys "{ENTER}", True

尝试...

SendKeys "{TAB}{TAB}{ENTER}"

I wasn't able to work out the Wininet for this specific website, but figured out a workaround using Chrome via Selenium Wrapper which allows you to automate functions in Chrome/Firefox very similar to Internet Explorer. 我无法为此特定网站制定Wininet,但想出了一种通过Selenium Wrapper使用Chrome的解决方法,该方法可让您自动执行与Internet Explorer非常相似的Chrome / Firefox功能。 Chrome downloads automatically go to the Downloads folder so it circumvented having to work with that dialog box. Chrome下载会自动转到“下载”文件夹,因此无需使用该对话框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM