Sample VBA code for downloading a file or web page from a URL:
{codecitation class=”engine parameters” width=”” }
‘— place this code in a standard module —‘
Option Compare Database
Option ExplicitPrivate 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 LongPublic Sub bimDownloadURLtoFile(pURL As String, _
pFullFilePath As String)Call URLDownloadToFile(0, pURL, pFullFilePath, 0, 0)
End Sub
”’ end code ”’ {/codecitation}
It is possible to pass the username and password on the URL like this:
http://username:[email protected]/pathtofile>
or
ftp://username:[email protected]/pathtofile>