I'm new to MSHTML.
I wanted to load a htm or html file (saved offline) into a text box to see how it parsed.
The object browser works correctly when entering code so no reference problem to MSHTML.
I wrote this simple function but keeps erroring on "Object or With Block Not Set"
I wanted to load a htm or html file (saved offline) into a text box to see how it parsed.
The object browser works correctly when entering code so no reference problem to MSHTML.
I wrote this simple function but keeps erroring on "Object or With Block Not Set"
Code:
Public Function getHTMLFile(strFile As String) As String
'Opens a htm or html "file" and parses the Text
Dim objDocument As MSHTML.HTMLDocument
Set objDocument = New MSHTML.HTMLDocument
'This supposedly tidys up the HTML prior to parsing?
'objDocument.body.outerHTML = strFile '"Object or With Block Not Set" --- Rem for now
objDocument.body.innerHTML = strFile '"Object or With Block Not Set"
getHTMLFile = objDocument.body.innerText
objDocument.Close
Set objDocument = Nothing
End Function