Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default 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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Links to Local Drive Instead of Same Folder TKS_Mark Excel Discussion (Misc queries) 1 May 21st 09 06:07 AM
Links to mapped drive change to refer to local hard drive SueD Links and Linking in Excel 1 May 8th 08 11:42 AM
How to copy a file from internet to local drive on VBA Kapa Excel Programming 0 April 9th 07 07:56 PM
Userform Local Drive & Network drive question Joel Mills Excel Programming 3 December 29th 04 10:43 PM
VBA : A picture from http://.../Image.gif VUILLERMET Jacques Excel Programming 2 October 1st 03 09:24 PM


All times are GMT +1. The time now is 01:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"