Dialog-Free Downloads
So you want to grab an Internet file, but think the Inet control is buggier than an ant's nest?
Need to start an online download but want to skip those annoying user dialog boxes?
This slice of code uses a sneaky API call to solve all your worries.
Just call the DownloadFile function, passing it your URL and local filename. The function will then use the API to download the file and return a True if successful.
Usage
MsgBox DownloadFile("http://www.vbworld.com", "c:\vbworld.htm")
Code
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
Public Function DownloadFile(URL As String, _
LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function