VBA TIPS
Download an html file from web

This API function makes Download a html file from the web site possible.

If download succeed, the variable returns 0.

This API function can be used not only a html file but also zip file or the files with other extension.

Change the Constance named strUrl suit to your needs.

Place following in the standard module.

Option Explicit

Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
                                           "URLDownloadToFileA" ( _
                                           ByVal pCaller As LongByVal szURL As String, _
                                           ByVal szFileName As String, _
                                           ByVal dwReserved As Long, _
                                           ByVal lpfnCB As LongAs Long

Sub DownloadFileFromWeb()
    Const strUrl As String = "http://www.puremis.net/excel/index.shtml"
    Dim strSavePath As String
    Dim returnValue As Long
    strSavePath = ThisWorkbook.Path & "\" & "Test.htm"
    returnValue = URLDownloadToFile(0, strUrl, strSavePath, 0, 0)
    If returnValue = 0 Then
        MsgBox "Sccess!"
    Else
        MsgBox "Did not success."
    End If
End Sub





| HOME |
Copyright © cellmasters.net - colo's junk room All Right Reserved
ABOUT
WORKS
THE CELL MASTERS
CONTACT
LINKS
Tips and Information about Microsoft Excel|Masaru Kaji aka Colo