首先,我不是程序員,我只想從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。謝謝。 –