首先,我不是程序员,我只想从https://www.nseindia.com/products/content/equities/equities/eq_security.htm下载报价历史记录,方法是在Excel中输入一些输入数据。我以某种方式设法将数据放入VBA中。任何人都可以请帮助我如何点击“以CSV格式下载文件”&将其保存到我的本地磁盘。NSE India报价历史记录下载自动化
这里是我的VBA代码:
Private Sub CommandButton1_Click()
Dim IE As Object
With IE
Set IE = CreateObject("InternetExplorer.Application")
'create new instance of IE. use reference to return current open IE if
'you want to use open IE window. Easiest way I know of is via title bar.
IE.Navigate "https://www.nseindia.com/products/content/equities/equities/eq_security.htm"
'go to web page listed inside quotes
IE.Visible = True
While IE.busy
DoEvents 'wait until IE is done loading page.
Wend
IE.document.ALL("symbol").Value = ThisWorkbook.Sheets("sheet1").Range("b1")
IE.document.ALL("series").Value = ThisWorkbook.Sheets("sheet1").Range("b2")
IE.document.getElementById("rdDateToDate").Click
IE.document.ALL("fromDate").Value = ThisWorkbook.Sheets("sheet1").Range("b4")
IE.document.ALL("toDate").Value = ThisWorkbook.Sheets("sheet1").Range("c4")
IE.document.getElementById("submitMe").Click
End With
End Sub
你能提供的值单元格引用的'Symbol'和'Series' ?理想您的'从日期'和'迄今日期',但它们并不重要 – Zac
符号= SBIN,系列=情商,从日期= 01-01-2012&到目前为止2012年1月12日 –
请提供代码下载文件后会自动关闭IE。谢谢。 –