ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to write a micro to download file at a URL save the file at the local PC (https://www.excelbanter.com/excel-programming/355438-how-write-micro-download-file-url-save-file-local-pc.html)

www.microsoft.com

How to write a micro to download file at a URL save the file at the local PC
 
How to write a micro to download file at a URL save the file at the local PC

Thanks



Robin Hammond[_2_]

How to write a micro to download file at a URL save the file at the local PC
 
Have a look at this windows api call:

URLDownloadToFile

Be aware thought that MS appears to have changed how this functions with
recent service packs / security updates, without any documentation or
notification, so that it will not retrieve dll, exe, or other "potentially
unsafe" files.

Robin Hammond
www.enhanceddatasystems.com

"www.microsoft.com" wrote in message
...
How to write a micro to download file at a URL save the file at the local
PC

Thanks




mudraker[_342_]

How to write a micro to download file at a URL save the file at the local PC
 

this id the code i use on a dily bases to download files from the
internet


'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
' Copyright ©1996-2003 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
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 DownLoadFileFromIntranet(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.
DownLoadFileFromIntranet = URLDownloadToFile(0&, _
sSourceUrl, sLocalFile, _
BINDF_GETNEWESTVERSION, _
0&) = ERROR_SUCCESS
End Function


Sub DownLoadFile()
Dim DownLoadFile As String
Dim sUrl As String

DownLoadFile$ = "c:\test down load.txt"
sUrl$ = "Replace this with full url for file to be downloaded"
If DownLoadFileFromIntranet(sUrl, DownLoadFile) = False Then
do something
else
do something else
end if
End Sub


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=520143



All times are GMT +1. The time now is 09:06 PM.

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