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
 

Some videos you may like

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

JP2112

Board Regular
Joined
Oct 27, 2008
Messages
237
Without a login and password, I'm afraid it will be near impossible to write or test any code that would help you.
 

JEscobed

New Member
Joined
Mar 22, 2011
Messages
9
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:

JP2112

Board Regular
Joined
Oct 27, 2008
Messages
237
Now everyone can login as you! Please delete your reply and send it as a PM instead.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,400
Messages
5,601,462
Members
414,451
Latest member
jrose7

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
Top