![]() |
Download .png
Hi. Does anybody know how to download a .png file from the internet using Excel XP. I want to pass the address to Excel, and then download that address (which will be a .png file) to my local hard drive. I have tried things in the past, without success, but because they didn't work I deleted the code so can't easily reproduce the code. Cheers. |
Download .png
Hello you may try these 2 examples you will have to adapt the web address ( not existing in this examples ) 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 Sub LancementProcedure() DownloadFile "http://theWebPage/picture.png", "C:\monImage1.gif" End Sub Public Function DownloadFile(ByVal sURL As String, ByVal sLocalFile As String) As Boolean Dim lngRetVal As Long DownloadFile = URLDownloadToFile(0&, sURL, sLocalFile, 0&, 0&) = ERROR_SUCCESS End Function ************* Sub recupererImageWeb_WinHttp() 'activate library : Microsoft WinHttp Services ,version 5.1 Dim b() As Byte Dim h As Long Dim oWinHttp1 As WinHttp.WinHttpRequest h = FreeFile Open "C:\monImage2.png" For Binary As #h Set oWinHttp1 = New WinHttp.WinHttpRequest oWinHttp1.Open "GET", _ "http://theWebPage/picture.png", False oWinHttp1.Send oWinHttp1.WaitForResponse (30) b() = oWinHttp1.ResponseBody Set oWinHttp1 = Nothing Put #h, 1, b() Close #h End Sub regards , michel -- michelxld ------------------------------------------------------------------------ michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367 View this thread: http://www.excelforum.com/showthread...hreadid=384071 |
Download .png
Thank you.
I tried the first example and it worked great, so didn't go on with the second one. I justmodified it so it saves it as a .png file (there is a reason for this!!). Cheers *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 07:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com