Yes! I managed to solve my problem. Thanks to everyone /
In my case, I had this type of input:
<p>Lorem ipsum dolor sit amet.</p> <p>Ut enim ad minim veniam.</p> <p>Duis aute irure dolor in reprehenderit.</p>
And I did not want the result to be glued together without tears.
Therefore, I first divided my input data for each <p> into an array of "paragraphs", then for each element I used the answer "Tim" to get the text from html (a very nice answer by the way).
In addition, I linked each cleared “paragraph” to this Crh(10) character for VBA / Excel.
Final code:
Public Function HtmlToText(ByVal sHTML As String) As String Dim oDoc As HTMLDocument Dim result As String Dim paragraphs() As String If IsNull(sHTML) Then HtmlToText = "" Exit Function End If result = "" paragraphs = Split(sHTML, "<p>") For Each paragraph In paragraphs Set oDoc = New HTMLDocument oDoc.body.innerHTML = paragraph result = result & Chr(10) & Chr(10) & oDoc.body.innerText Next paragraph HtmlToText = result End Function
Magalhães lage
source share