Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Links to Local Drive Instead of Same Folder | Excel Discussion (Misc queries) | |||
Links to mapped drive change to refer to local hard drive | Links and Linking in Excel | |||
How to copy a file from internet to local drive on VBA | Excel Programming | |||
Userform Local Drive & Network drive question | Excel Programming | |||
VBA : A picture from http://.../Image.gif | Excel Programming |