Download files using MSXML2.XMLHTTP

P

p3plyr

i am having a little trouble downloading a file using MSXML2.XMLHTTP

the code below works great *if* you can get a link that leads directly to
the file, as in the example below

Quote:
Private Sub test()
Dim objHTTP As Object
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
Dim stl As String
Dim rt

stl = "http://slmap.hostingweb.us/test/1.zip"
objHTTP.Open "GET", stl, False, "test", "test" 'unme/pwd

objHTTP.send
rt = objHTTP.responseBody

Dim oADOStream
Set oADOStream = CreateObject("ADODB.Stream")
oADOStream.Type = 1
oADOStream.Mode = 3
oADOStream.Open
oADOStream.Write rt
oADOStream.SaveToFile "c:\anyfilename.zip"
oADOStream.Close
Set oADOStream = Nothing

Set objHTTP = Nothing
End Sub

unfortunately it 'freezes' when trying to pull a file from a different sort
of link, something like:

http://anysite.com/231/en-us/abc/gogetit?id=3456&part=3&saveas=1.zip

i think it freezes because the link wants to open a dialogue box or
something. i have tried to retool the link, or find another one that is
directly connected to the file, but on some of these monster servers with the
way they deal with uploads and downloads the best i can do is the link i just
showed. it is one of those email attachement links.

has anybody had any experience with this?

using a webbrowser you can navigate to the link, but the webbrowser is
generlaly much slower so i want to go the MSXML2.XMLHTTP route if possible.
it has been working great for just about everything, but i ran into this snag
and need some help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top