Error Downloading xls File from Web

JEscobed

New Member
Joined
Mar 22, 2011
Messages
9
Hi,
I was hoping someone could please help. I have a piece of code that I've been using to download a csv file from the web, but when I tried to use it to download an xls file from another website, the file downloaded does not have any data. I believe the new website requires a login, also. Could someone take a look?

Jill



Sub csvdl()
Dim myURL As String
Dim WinHttpReq As Object
Dim c As Range

'S&P500
myURL = "http://www.standardandpoors.com/prot/logincheck?SPREFERER=/prot/spf/docs/indices/SPUSA-500-USDUF--P-US-L--Constituents.xls"

Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myURL, False
WinHttpReq.Send

myURL = WinHttpReq.ResponseBody
If WinHttpReq.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.ResponseBody
oStream.SaveToFile ("C:\MyDownloads\SP500.csv")
oStream.Close
End If

End sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Without a login and password, I'm afraid it will be near impossible to write or test any code that would help you.
 
Upvote 0
I can provide my password/login, none of the info I'm pulling is proprietary. (You just have to register on the site to get a login)
 
Last edited by a moderator:
Upvote 0
Now everyone can login as you! Please delete your reply and send it as a PM instead.
 
Upvote 0

Forum statistics

Threads
1,214,630
Messages
6,120,634
Members
448,973
Latest member
ChristineC

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