I'm trying to strip HTML from a string and found two methods in this SO thread.
The code for the first answer works but uses late binding.
With CreateObject("htmlfile")
.Open
.write "<p>foo <i>bar</i> <u class='farp'>argle </zzzz> hello </p>"
.Close
MsgBox "text=" & .body.outerText
End With
The code for the alternative answer, which uses early binding, gives a compile error ("Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic").
Public Function StripHtml(inputHtml As String) As String
With New HTMLDocument
.Open
'Following line gives compile error
.write "<p>foo <i>bar</i> <u class='farp'>argle </zzzz> hello </p>"
.Close
StripHtml = .body.outerText
End With
End Function
My questions:
- Is the alternative answer simply not the equivalent?
- Is there an early binding equivalent to the first answer, which works?
- Why does
CreateObject("htmlfile")
work at all when I cannot find that object type in the object browser?