Loading HTML table in MS Access

I am trying to import a table from the following link into my database: http://www.abif.cl/tasas.php?tipo=5

I am trying to do this by loading the page as an HTML file into a directory through VBA, and then creating a linked table.

This works great when I download it manually via Chrome using the “Download Full Web Page” option in the “Save As” section.

However, when I load a webpage using VBA, I get a Reserved Error (-5016) when I try to link a table.

Explanation: An error occurred while trying to load the page in HTML; rather, this happens after I try to link the table with the loaded HTML (it does not occur if the HTML was loaded manually through a browser)

Here is the VBA that I use to load HTML:

Option Compare Database

Option Explicit

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( _
    ByVal strURL As String, _
    ByVal strLocalFilename As String) _
    As Long

    Dim lngRetVal As Long

    lngRetVal = URLDownloadToFile(0, strURL & vbNullChar, strLocalFilename & vbNullChar, 0, 0)

    DownloadFile = lngRetVal

End Function

, , - , ! , " -" VBA?

!

+4
1

HTML , . , - , / . .

Public Function SaveHTML(strURL As String, strOutFile As String)

Dim IE As Object
Dim i As Long
Dim FF As Integer


Set IE = CreateObject("Internetexplorer.Application")
IE.Visible = False
IE.Navigate strURL
Do
Loop While IE.Busy

'Creates a file as specified
' this will overwrite an existing file if already exists
CreateObject("Scripting.FileSystemObject").CreateTextFile strOutFile

FF = FreeFile
Open strOutFile For Output As #FF

With IE.Document.Body
    Print #FF, .OuterHtml & .InnerHtml
End With

Close #FF

IE.Quit
'Set IE = Nothing

End Function
0

All Articles