Excel中的VBA - Internet Explorer下载XML - 另存为对话框

时间:2014-11-24 17:45:06

标签: excel-vba vba excel

我正在将Climate XML数据下载到Excel 2013中。我需要自动化该过程,我可以立即导航到预先加载了正确参数的正确页面。我可以单击“确定”按钮,然后出现“Internet Explorer - 打开/保存/取消”对话框。

我在Windows 7中尝试过各种选项来捕获Windows事件32770(??),但我不确定如何编写代码。我只想将文件保存为c:\temp.xml

我不想使用SendKeys方法,因为它太不可靠了。任何人都可以建议一种方法来处理对话吗?

Dim htm As Object
Dim IE As Object

Dim Doc As Object
Set IE = CreateObject("internetexplorer.application")
IE.Visible = True

IE.navigate "http://ec.europa.eu/environment/ets/exportEntry.do?form=transaction&destinationAccountHolder=&startDate=01%2F06%2F2009&destinationRegistry=-1&originatingAccountType=-1&endDate=01%2F05%2F2010&transactionID=&suppTransactionType=-1&originatingAccountHolder=&transactionType=-1&languageCode=en&destinationAccountNumber=&destinationAccountType=-1&toCompletionDate=&originatingRegistry=-1&destinationAccountIdentifier=&fromCompletionDate=&originatingAccountIdentifier=&transactionStatus=4&originatingAccountNumber=8&currentSortSettings="

Do While IE.readystate <> 4: DoEvents: Loop

Set Doc = CreateObject("htmlfile")
Set Doc = IE.document

Doc.getelementbyID("btnOK").Click

Set IE = Nothing

0 个答案:

没有答案