I posted a question earlier in the week regarding HTML to Excel conversion that worked well for me. The sample macro code I was given did a great job of converting the code from HTML format into an Excel cell (thanks Siddharth Rout!). The problem I'm running into now and can't seem to find an answer to anywhere has to do with how the IE object handles paragraphs, breaks, and list items in Excel. p, br, and li move the text into cells below the origin cell, overwriting any data that was in those cells. Is there any way to get the block of HTML to display in only one cell(meaning each new line tag would just create a new line in the same cell)?
VBA code
Sub Sample()
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
Sample HTML
<p> Here are some possible uses:</p> <ul> <li><font color = "red"> syntax highlighting code snippets</font></li> <li style ="font-weight:bold; color: orange">validating credit card numbers, phone numbers, and zip codes</li> <li style = "font-style: italic">styling email addresses and tags</li> </ul>
Sample Output that is displaying on multiple rows (would like to display on multiple rows in one cell - similar to the way shift+enter works)
Here are some possible uses:
syntax highlighting code snippets
**validating credit card numbers, phone numbers, and zip codes**
*styling email addresses and tags*