![]() |
Copy picture from http to local drive?
It is possible via Excel VBA to fetch an image placed on a standard http
address and copy it to a folder on the local harddrive? Like: Copy http://www.domain.net/picture.jpg To C:\Pictures\picture.jpg TIA, CE |
Copy picture from http to local drive?
It is possible as long as you know the URL for the Pic Past all the following code into a normal module & run PicFetcher Private Declare Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" _ (ByVal pCaller As Long, _ ByVal szURL As String, _ ByVal szFileName As String, _ ByVal dwReserved As Long, _ ByVal lpfnCB As Long) As Long Private Const ERROR_SUCCESS As Long = 0 Private Const BINDF_GETNEWESTVERSION As Long = &H10 Private Const INTERNET_FLAG_RELOAD As Long = &H80000000 Public Function DownloadFile(sSourceUrl As String, _ sLocalFile As String) As Boolean 'Download the file. BINDF_GETNEWESTVERSION forces 'the API to download from the specified source. 'Passing 0& as dwReserved causes the locally-cached 'copy to be downloaded, if available. If the API 'returns ERROR_SUCCESS (0), DownloadFile returns True. DownloadFile = URLDownloadToFile(0&, _ sSourceUrl, sLocalFile, _ BINDF_GETNEWESTVERSION, _ 0&) = ERROR_SUCCESS End Function Sub PicFetcher() Dim sURL As String Dim sSave As String sURL = "http://i.pbase.com/o6/34/123234/1/87074423.9nCO7UwC.071007IMG_4761.jpg" sSave = "c:\temp\MyDownLoadedPic.jpg" Call DownloadFile(sURL, sSave) End Sub -- mudraker If my reply has assisted or failed to assist you I welcome your Feedback. www.thecodecage.com ------------------------------------------------------------------------ mudraker's Profile: http://www.thecodecage.com/forumz/member.php?userid=18 View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=32769 |
Copy picture from http to local drive?
Cool - it works :-)
And, what an awesome picture you used as demo :-) Thanks - very handy little function in deed... CE mudraker wrote: It is possible as long as you know the URL for the Pic Past all the following code into a normal module & run PicFetcher Private Declare Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" _ (ByVal pCaller As Long, _ ByVal szURL As String, _ ByVal szFileName As String, _ ByVal dwReserved As Long, _ ByVal lpfnCB As Long) As Long Private Const ERROR_SUCCESS As Long = 0 Private Const BINDF_GETNEWESTVERSION As Long = &H10 Private Const INTERNET_FLAG_RELOAD As Long = &H80000000 Public Function DownloadFile(sSourceUrl As String, _ sLocalFile As String) As Boolean 'Download the file. BINDF_GETNEWESTVERSION forces 'the API to download from the specified source. 'Passing 0& as dwReserved causes the locally-cached 'copy to be downloaded, if available. If the API 'returns ERROR_SUCCESS (0), DownloadFile returns True. DownloadFile = URLDownloadToFile(0&, _ sSourceUrl, sLocalFile, _ BINDF_GETNEWESTVERSION, _ 0&) = ERROR_SUCCESS End Function Sub PicFetcher() Dim sURL As String Dim sSave As String sURL "http://i.pbase.com/o6/34/123234/1/87074423.9nCO7UwC.071007IMG_4761.jpg" sSave = "c:\temp\MyDownLoadedPic.jpg" Call DownloadFile(sURL, sSave) End Su |
Copy picture from http to local drive?
Glad it helped you -- mudraker If my reply has assisted or failed to assist you I welcome your Feedback. www.thecodecage.com ------------------------------------------------------------------------ mudraker's Profile: http://www.thecodecage.com/forumz/member.php?userid=18 View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=32769 |
All times are GMT +1. The time now is 06:48 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com