med
03-24-2016, 08:06 AM
Hi,
i'm trying to download *.csv and xls file from a website into my C drive.I'm using the code below .
url="myurl/levelt1/level11/mycsvfile.csv"
Set HttpQuery = CreateObject("Microsoft.XMLHTTP")
HttpQuery.Open "GET", url, False, myusername, myPasswd
HttpQuery.send
url = HttpQuery.responseBody
If HttpQuery.Status = 200 Then
Set wstream = CreateObject("ADODB.Stream")
wstream.Type = 1
wstream.Open
wstream.Write HttpQuery.responseBody
wstream.SaveToFile "c:\test\myfile.csv", 2
wstream.Close
End If
The Problem: this code create the file on my C drive , but its content is not correct , the file contains the html code of the authentication page of the web site.
the credentials i'm using are corrects , in addition when i launch my URL in my Internet explorer the download is done without problems.
I'm really stuck on this , any help please ?
thanks in advance.
Med.
i'm trying to download *.csv and xls file from a website into my C drive.I'm using the code below .
url="myurl/levelt1/level11/mycsvfile.csv"
Set HttpQuery = CreateObject("Microsoft.XMLHTTP")
HttpQuery.Open "GET", url, False, myusername, myPasswd
HttpQuery.send
url = HttpQuery.responseBody
If HttpQuery.Status = 200 Then
Set wstream = CreateObject("ADODB.Stream")
wstream.Type = 1
wstream.Open
wstream.Write HttpQuery.responseBody
wstream.SaveToFile "c:\test\myfile.csv", 2
wstream.Close
End If
The Problem: this code create the file on my C drive , but its content is not correct , the file contains the html code of the authentication page of the web site.
the credentials i'm using are corrects , in addition when i launch my URL in my Internet explorer the download is done without problems.
I'm really stuck on this , any help please ?
thanks in advance.
Med.