html text with tags to formatted text in an excel cell c# code example

Example: excel vba HTML text with tags to formatted text in an cell

Sub TestHTML()
    Const HTML = "<html><p>This <b>bold</b> and <i>italic</i> came from HTML tags.</p></html>"
    Clipboard HTML
    [A1].PasteSpecial "Unicode Text"
End Sub


Function Clipboard$(Optional s$)
    Dim v: v = s  'Cast to variant for 64-bit VBA support
    With CreateObject("htmlfile")
    With .parentWindow.clipboardData
        Select Case True
            Case Len(s): .setData "text", v
            Case Else:   Clipboard = .GetData("text")
        End Select
    End With
    End With
End Function

Tags:

Vb Example