Download JPEGs from URL

Heathy

Registered User.
Local time
Today, 03:30
Joined
Jul 6, 2006
Messages
17
Hi.

I have an interesting task to carry out with an excel spreadsheet. In certain columns of the spreadsheet I have urls which point to JPEG images on the net. I need to download these images and name the files appropriately.

Not sure exactly how I am going to achieve this. I have found third party software, but none of which will allow me to pass the urls either through import/export or command line options in order to automate the task.

Any ideas would be greatly appreciated.

Thanks.

Stuart.
 
The following function should provide a starting point. It downloads a file from the specified Source URL and writes it to the specified File Path:
Code:
Public Function SaveHTTPPicture( _
    ByVal sUrl As String, _
    ByRef sFilePath As String)

    Dim byteData() As Byte
    Dim ff As Integer
    Dim XMLHTTP As Object

    Set XMLHTTP = CreateObject("MSXML2.XMLHTTP")

    XMLHTTP.Open "GET", sUrl, False
    XMLHTTP.send
    byteData = XMLHTTP.responseBody

    Set XMLHTTP = Nothing

    ff = FreeFile
    Open sFilePath For Binary Access Write As #ff
        Put #ff, , byteData
    Close #ff

End Function
Example:
Code:
SaveHTTPPicture "http://www.mysite.com/myimage.jpg", _
   "C:\MyFolder\myimage.jpg"
 
Thank you.

Gives me exactly what I was after.
 

Users who are viewing this thread

Back
Top Bottom