如何使用VBA在IE中自动下载对话框?

我在这里是全新的,只用了大约6个月的VBA。 毋庸置疑,这里和其他一些地方的论坛post对我来说是非常有帮助的。

我正在尝试开发一个脚本,从Morningstar获取数据并将其复制到excel中(请注意,这是为了我个人的非商业用途)。 我相信,我可以编写大部分所需的VBA,但是当IE下载对话框popup时,我自动select“保存”。 我已经看到了一些相关的post,但没有任何我已经能够反向工程,迄今为止,任何帮助将不胜感激!

目前为止我的代码如下:

Sub Download_Morningstar_Data() ' ' Download Morningstar Data ' my_Page = "http://financials.morningstar.com/balance-sheet/bs.html?t=SCCO&region=usa&culture=en-US" Set IE = CreateObject("InternetExplorer.Application") With IE .Visible = True .Navigate my_Page Do Until .ReadyState = 4: DoEvents: Loop End With Application.EnableEvents = True IE.ExecWB 17, 0 Do Until IE.ReadyState = 4: DoEvents: Loop IE.ExecWB 12, 2 ' click the "export" button IE.Document.parentWindow.execScript "SRT_stocFund.Export()" 

这就是我卡住的地方

请注意,我正在使用Windows 7,Excel 2010和IE11。

提前致谢!

使用

Workbooks.Open(“ http://financials.morningstar.com/ajax/ReportProcess4CSV.html?&t=XNYS:SCCO&region=usa&culture=en-US&cur=&reportType=bs&period=12&dataType=A&order=asc&columnYear=5&curYearPart=1st5year&rounding=3&view=raw&r = 404338&denominatorView = raw&number = 3 “)

仔细看看URL,你几乎可以改变URL中的每一个设置。

在IE或Chromedebugging模式下查看morningstar页面,您可以轻松找出哪个URL(这里使用的)创build了CSV文件。

在这里输入图像说明