Hi everyone,
I am trying to download csv file from the nse equity stock watch ("https://www.nseindia.com/live_market/dynaContent/live_watch/equities_stock_watch.htm"). I download it manually by clicking on "Download in csv" text on to the right of the webpage. Is there a way how I could automate it using excel vba. i have small bit of code but it isn't working. Really appreciate if someone could provide a solution. It is failing at
****** (strFile = ieDoc.getElementById("datacsv") )**** below is the code for the same. the code returns ["Object'] for strfile. and hence it fails to Open,
I am trying to download csv file from the nse equity stock watch ("https://www.nseindia.com/live_market/dynaContent/live_watch/equities_stock_watch.htm"). I download it manually by clicking on "Download in csv" text on to the right of the webpage. Is there a way how I could automate it using excel vba. i have small bit of code but it isn't working. Really appreciate if someone could provide a solution. It is failing at
****** (strFile = ieDoc.getElementById("datacsv") )**** below is the code for the same. the code returns ["Object'] for strfile. and hence it fails to Open,
Code:
Dim fileStream As ADODB.Stream
Dim xmlHTTP As MSXML2.XMLHTTP60
Dim strURL As String
Dim strFile
Dim ie As InternetExplorer, ieDoc As HTMLDocument
strURL = "https://www.nseindia.com/live_market/dynaContent/live_watch/equities_stock_watch.htm"
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate strURL
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Set ieDoc = ie.document
strFile = ieDoc.getElementById("datacsv")
Set xmlHTTP = New MSXML2.XMLHTTP60
xmlHTTP.Open "GET", strFile
xmlHTTP.send
Last edited by a moderator: