saving file not working from web site

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
755
Office Version
  1. 365
  2. 2010
Code:
Dim myURL As String
myURL = "http://test/Fxrates.xlsx"


Dim HttpReq As Object
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
HttpReq.Open "GET", myURL, False, "username", "password"
HttpReq.send






myURL = HttpReq.responseBody
If HttpReq.Status = 200 Then
     Set oStrm = CreateObject("ADODB.Stream")
    oStrm.Open
    oStrm.Type = 1
    oStrm.Write HttpReq.responseBody
    oStrm.SaveToFile ThisWorkbook.Path & "\" & "Fxrates.xlsx", 2 ' 1 = no overwrite, 2 = overwrite
    oStrm.Close
    
    
End If

soemone sent me this code, but it doesn't seem to work....when I run it step by step ...it seems to be messing up after "myURL = HttpReq.responseBody".....myURL no longer refers to the link but it now says "?????????????????????????????????????????????????????=???????????????????????????????????????????•??????????????????????????????????›????????????????????????????????????????????????????????????????????????????????????????????????????????8???????????????????????????????????????????????????????????????????????????????????????????‰‰‰??????8?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????6??????????????????????6????????????????????????????????????????????????????????????????????†???5?????????????????????????????????????????????????????????????????????????"


also "If HttpReq.Status = 200" doesn't seem to be true because it doesn't go through the code within the if statement.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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