ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I load a file from URL (https://www.excelbanter.com/excel-programming/368507-how-do-i-load-file-url.html)

Peter[_58_]

How do I load a file from URL
 
Very simple question ...

what methods are there to load a file from a URL and then store it in a
filesystem file?

I'm doing this from VBA excel, but dont actually want (need) the
information inside of excel - but that is where I need to initiate the
transfer.

A quick pointer to an approrpiate library/class would be appreciated.


MaC

How do I load a file from URL
 

Uzytkownik "Peter" napisal w wiadomosci
oups.com...
Very simple question ...

what methods are there to load a file from a URL and then store it in a
filesystem file?

I'm doing this from VBA excel, but dont actually want (need) the
information inside of excel - but that is where I need to initiate the
transfer.

A quick pointer to an approrpiate library/class would be appreciated.


You can use API's for it. In short like below:

Public 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

Sub GetURLFile(URL As String, Filename As String)
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, Filename, 0, 0)
If lngRetVal < 0 Then
MsgBox "Problem with download " & URL & " file name " & Filename
End If
End Sub

'E.G.using:
Sub Test()
GetURLFile http://www.yourserver.com/fileTOdownload.jpg, "c:\downloaded.jpg"
End Sub


Regards
Mario



Peter[_58_]

How do I load a file from URL
 
Hi Mario,

many thanks this is exactly what I wanted .. and already packaged into
a standrd .dll.

As a matter of interest, if there some way I could have discovered this
existence of this function easily - without having to ask the worldwide
community of developers?

Many thanks anyway.

Peter



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com