I want to open a local HTML file and store it as an HTMLDocument so I can scrape it into excel. However all the available information is for html pages on the web. So for instance this code works great for www.bbc.co.uk but doesn't work for a local file:
Sub queryXMLlocal()
Dim XMLPage As New MSXML2.XMLHTTP60
Dim HTMLDoc As New MSHTML.HTMLDocument
Debug.Print Application.ActiveWorkbook.Path
XMLPage.Open "GET", "<filepath>\KOND.html", False
XMLPage.send
If XMLPage.Status <> 200 Then
MsgBox "Problem" & vbNewLine & XMLPage.Status & " - " & XMLPage.statusText
Exit Sub
End If
End Sub
Alternatively using
Sub GetHTMLDocument()
Dim IE As New SHDocVw.internetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
IE.Visible = True
IE.navigate "https://www.bbc.co.uk/"
Do While IE.readyState <> READYSTATE_COMPLETE
Loop
' Wait while IE loading...
Set HTMLDoc = IE.Document
end sub
works but when I use a local file I get the error:
"object invoked has disconnected from its client"
Can I just use HTMLdocument.open
? Although I cannot get this to work either.