VBA:点击网站上的保存按钮

时间:2017-07-11 08:25:26

标签: vba internet-explorer

我发现了很多类似的问题,但我没有解决方案。 我在Internet Explorer中使用VBA(Excel)进行导航。我的代码填写了一些框,然后单击下载按钮。现在,对话框显示"打开","保存"和"取消"。我的问题是:如何选择"另存为"与VBA?启动子版后,我不想手动进行任何进一步的点击。

非常感谢。

Sub getcsv()
Dim i As Long
Dim URL, sCurrency As String
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Dim HWNDSrc As Long
Dim wbksdr As Workbook
Dim sdestpath As String

Set wbksdr = ThisWorkbook

sdestpath = "xxx\test.csv"

sCurrency = "USD"
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = "https://rtdata.dtcc.com/gtr/inquiry.do"
IE.Navigate URL
Do While IE.readystate = 4: DoEvents: Loop
Do Until IE.readystate = 4: DoEvents: Loop

Application.StatusBar = URL & " Loaded"

HWNDSrc = IE.HWND
SetForegroundWindow HWNDSrc


IE.Document.getelementbyid("dailySearch_assetClassification").Value = "IR"
IE.Document.getelementbyid("dailySearch_notionalRangeLow").Value = 100
IE.Document.getelementbyid("dailySearch_notionalRangeHigh").Value = 5000000000#
IE.Document.getelementbyid("dailySearch_currency").Value = sCurrency
IE.Document.All("dailySearch_displayType_c").SetAttribute ("checked")
IE.Document.getelementbyid("dailySearch_SearchButton").Click


Application.Wait Now + #12:00:03 AM#
Application.SendKeys "%{S}"

Application.Wait Now + #12:00:01 AM#

IE.Quit

End Sub

0 个答案:

没有答案