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.