Discussion:
VBScript download csv file
(too old to reply)
Michael
2005-12-15 16:21:02 UTC
Permalink
Need some help downloading a CSV file from a website. However is not a
standard file on the site. The CSV file is created from a POST on the
website. I can get access to the file, that is not my problem. The question
I have is this; is there a way to suppress the file download dialog and save
the file in a certain location on the intranet web server that I am using?
Thanks for any help.
Bill James
2005-12-16 00:46:40 UTC
Permalink
I don't know if it will work in your case, but here's a script I use to do that same thing manually. If it works you just need to take out the msgbox to automated it. The script downloads the file to the same directory as the script, which is what I want, but that could be easily modified. Could use a little more error checking for an automated task I suppose, but as I said I just use this manually.

MsgBox GetSource("http://servername/path/filename.csv", _
CreateObject("WScript.Shell").CurrentDirectory & "\myfilename.csv")

Function GetSource(source, target)

With CreateObject("MSXML2.XMLHTTP")
.open "GET", source, False
.send
sText = .responseText
End With

With CreateObject("Scripting.FileSystemObject").OpenTextFile(target, 2, True)
.Write sText
.Close
End With

GetSource = source & vbcrlf & vbcrlf & " saved as:" & vbcrlf & vbcrlf & target

End Function
--
Bill James
Microsoft MVP - Shell/User

Windows VBScript Utilities » www.billsway.com/vbspage/
Windows Tweaks & Tips » www.billsway.com/notes_public/
Post by Michael
Need some help downloading a CSV file from a website. However is not a
standard file on the site. The CSV file is created from a POST on the
website. I can get access to the file, that is not my problem. The question
I have is this; is there a way to suppress the file download dialog and save
the file in a certain location on the intranet web server that I am using?
Thanks for any help.
wayne dawson
2006-01-29 04:20:21 UTC
Permalink
Assuming you haven't been able to remove the dialog box, the way I've done
it is by using the run method, and shelling out to either curl or wget.

Kind of a hack, but it works.

Loading...