Downloading files on the network with VBA code

Source: Internet
Author: User
Tags file url save file
A few days ago with the MVP old K to discuss how to download a file from the network to the local machine, the code is posted to share with you. In addition, I see Zhang Zhirong before the time needed this code, do not know now still need. Code applies to Vba,vb,vbs.

Dim H, S
Set H = CreateObject ("Microsoft.XMLHTTP")
H.open "Get", " http://www.yt-e.com/a.exe", False?? ' The file URL in the network
H.send
Set S = CreateObject ("ADODB.") Stream ")
S.type = 1
S.open
S.write H.responsebody
S.savetofile "C:\a.exe", 2? ' Save file name locally
S.close


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.