Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Any Filles From http:// with VBA

Status
Not open for further replies.

larryjr

Technical User
Aug 27, 2001
20
0
0
JP
I finally got the conclusion to this subject and
here is the sample code.
Please note that your PC needs MDAC before you run this.
You will get it from

<SCRIPT LANGUAGE = &quot;VBScript>
' ********************************************************
Const adTypeBinary = 1
Const adSaveCreateOverwrite = 2
Const adModeReadWrite = 3

set myXML = WScript.CreateObject(&quot;Microsoft.XMLHTTP&quot;)
sDest = &quot;C:\MYDOCU~1\tetscopy.gif&quot;
sSource = &quot; ' or If you like to copy a text file
' sSource =&quot; ' and sDest = &quot;C:\MYDOCU~1\testcopy.js&quot;
myXML.open &quot;GET&quot;, Trim(&quot; &quot; & sSource & &quot; &quot;), False
myXML.send
If (myXML.status = 200) Then
Set stream = WScript.CreateObject(&quot;adodb.stream&quot;)
stream.type = adTypeBinary
stream.mode = adModeReadWrite
stream.open
stream.write myXML.responseBody
stream.savetofile sDest, adSaveCreateOverwrite
stream.close
Set stream = Nothing
Else
' You can write any for waiting or cancelling to DL.
End If
Set myXML = Nothing
' ***************************************************
</SCRIPT>

Enjoy this for collection any files you like from web.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top