Home > How-To Library > Internet

How to Download a file from the Internet -- without getting a dialog box (in two ways)

**************************************************************** * © 2007 CodeItBetter http://www.codeitbetter.com * * This notice MUST stay intact for legal use * ****************************************************************
'Method 1: 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 Sub Form_Load() Dim llRetVal As Long llRetVal = URLDownloadToFile(0, "http://www.yahoo.com", "c:\Temp.htm", 0, 0) End Sub 'Method 2: Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long Public Sub DownloadFile(FileURL As String) Dim sDownload As String sDownload = StrConv(FileURL, vbUnicode) Call DoFileDownload(sDownload) End Sub

If you would like to submit your code here please us. Do not forget to mention your name. We are always thankful to each and everyone of you who submitted their code here.