Tom
Wed May 07 15:31:40 CDT 2008
On May 7, 2:08 pm, rdreyes <rdre...@discussions.microsoft.com> wrote:
> Hi all.
>
> In this URL is the SDN.xml file
>
>
http://www.treas.gov/offices/enforcement/ofac/sdn/sdn.xml
>
> I need to automatically copy the file to hard disk.
>
> Thanks for your help.
Or without requiring a third party download ...
sURL = "
http://www.treas.gov/offices/enforcement/ofac/sdn/sdn.xml"
aTemp = split(sURL, "/")
sFileName = aTemp(Ubound(aTemp))
sFilePath = ".\" ' current active folder - modify as needed
DownBinFile(sFilePath & sFileName, sURL)
wsh.echo "Done"
' Source Michael Harris & Alex K. Angelopoulos
' modified by TGL 2003 - 2008
'
http://groups.google.com/groups?selm=OxJBkB8xCHA.2120%40TK2MSFTNGP11
&
'
http://www.google.com/groups?selm=%23v1%23CmirAHA.2132%40tkmsftngp05
'
Sub DownBinFile(FilePath, sURL)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
' Create an xmlhttp object:
set oXML = CreateObject("MSXML2.XMLHTTP")
oXML.open "GET", sURL, False
oXML.send
If (oXML.Status = 200) Then
with CreateObject("ADODB.Stream")
.Open
.Type = adTypeBinary
.Write oXML.ResponseBody
.SaveToFile FilePath, adSaveCreateOverWrite
.Close
end with ' oStream
Else
WScript.Echo "Error Number: " & oXML.Status
WScript.Echo "Error Text: " & oXML.StatusText
End If
End Sub
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/