Sub test()
Dim Code$, i&, elem As Object, t, x&, ok As Boolean
Code = "<html><body><div><font color=red face=Algerian>toto<B> la <em>grosse</em> fr$itte</B></font><font size=7><S>toto</S><B>la grosse anguille</B></font></div></body></html>"
Code = Replace(Code, "=", "$=") 'le fait de mettre le "$" ajoute ou appui les guillemets en DOM (découverte)
With CreateObject("htmlfile")
.body.innerhtml = Code
For Each elem In .body.all 'attention le signe egal peut etre du text alors on corrige le replace
If elem.Children.Length = 0 Then If elem.innertext Like "*$*" Then elem.innerhtml = Replace(elem.innertext, "$", "")
Next
For Each elem In .body.all
If elem.ChildNodes.Length > 1 And elem.ChildNodes.Item(0).NodeType = 3 Then
For Each nod In elem.ChildNodes
If nod.NodeType = 3 Then
Set pre = .createelement("pre"): pre.innerhtml = Replace(nod.NodeValue, " ", "|")
elem.InsertBefore pre, nod.NextSibling
elem.RemoveChild (nod)
End If
Next
End If
Next
' Debug.Print .body.innerhtml
Code = Replace(.body.outerhtml, "$", "") 'on peut maintenant supprimer les "$"
Code = Indenter_HTML_XML_Code(Code)
Code = Replace(Replace(Replace(Code, "<PRE>", ""), "</PRE>", ""), "|", " ")
MsgBox Code
End With
fichier = Environ("userprofile") & "\Desktop\fichier de sortie.html"
x = FreeFile: Open fichier For Output As #x: Print #x, Code: Close #x
End Sub