Show HTML code as "HTML preview" within an excel cells

Anonymous
2014-10-13T12:38:10+00:00

Hello,

I have a row with cells containing text strings with HTML code inside. I would like to see just HTML preview (no code) within cells. I would like to still have HTML code inside the cell, but it apears as text without <> etc...

Is that possible?

I tried

Sub Sample2()

    Dim Ie As Object

    Set Ie = CreateObject("InternetExplorer.Application")

    With Ie

        .Visible = False

        .Navigate "about:blank"

        .document.body.InnerHTML = Sheets("Sheet1").Range("A1").Value

        .document.body.createtextrange.execCommand "Copy"

        ActiveSheet.Paste Destination:=Sheets("Sheet1").Range("A1")

        .Quit

    End With

End Sub

I get stuck with this line .document.body.createtextrange.execCommand "Copy"

could someone help me?

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

12 answers

Sort by: Most helpful
  1. Andreas Killer 144K Reputation points Volunteer Moderator
    2014-10-15T13:47:57+00:00

    macro stopped at the T.execCommand "SelectAll"

    >>Object doesnt support this property or method.

    Then the code is not compatible with your OS or your version of IE.

    0 comments No comments
  2. Anonymous
    2014-10-15T14:02:49+00:00

    i have the newest IE and windows 8...

    but thanks for all

    i will try something more..

    0 comments No comments
  3. Anonymous
    2014-10-15T14:06:04+00:00

    Did you give my example a try?  It worked for me in IE 11, Windows 7, where your code and Andreas' code did not.

    Eric

    0 comments No comments
  4. Anonymous
    2014-10-15T14:54:21+00:00

    honestly, i tried, but i didnt Set a reference to MS Forms 2.0 as you proposed there. I am not sure what you mean with that. So it is not working for me.

    sorry

    0 comments No comments
  5. Andreas Killer 144K Reputation points Volunteer Moderator
    2014-10-15T15:02:37+00:00

    Did you give my example a try? 

    I must apologize, it would have been better if I had not replied to this post. Your code works perfect.

    I was too talkative and just wanted to explain why his code does not work.

    Andreas.

    0 comments No comments