Download csv file using excel

lawvictor

New Member
Joined
Jul 29, 2017
Messages
27
Hi everyone,

I am trying to download a file from the following site

Access Denied

. Manually I will be able to download the csv file by clicking on the text "Download in csv". I am trying to automate the downloading process in excel. I am unable to find out why it is failing. I have a code which is trying to get the url by id and download the file and save it at the requirted lcoation. but it always fail trying to get the url. Could someone guide me on this.

Dim fileStream As ADODB.Stream
Dim xmlHTTP As MSXML2.xmlHTTP
Dim strURL As String
Dim strFile As String
Dim ie As InternetExplorer
Dim 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("Download in csv") *** its failing here****

thanks,
law
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi everyone,

I am trying to download a file from the following site

"https://www.nseindia.com/live_market/dynaContent/live_watch/equities_stock_watch.htm"

. Manually I will be able to download the csv file by clicking on the text "Download in csv". I am trying to automate the downloading process in excel. I am unable to find out why it is failing. I have a code which is trying to get the url by id and download the file and save it at the requirted lcoation. but it always fail trying to get the url. Could someone guide me on this.

Dim fileStream As ADODB.Stream
Dim xmlHTTP As MSXML2.xmlHTTP
Dim strURL As String
Dim strFile As String
Dim ie As InternetExplorer
Dim 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("Download in csv") *** its failing here****

thanks,
law[/QUOTE]
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top