Link to home
Start Free TrialLog in
Avatar of randys106
randys106Flag for United States of America

asked on

Paste/parse HTML into excel

I hate when what should be simple is complicated.  

I want to paste the HTML from the body of a website into my spreadsheet.  When I go to the website, view the source, copy it, and paste it to a cell, the HTML is parsed like I need it (every line in a different cell).  But from VBA when I paste all the HTML is in one cell.  How do I fix this?

Here is my code and spreadsheet.  Note that there are two sheets (one like VBA gives it to me, one like I want it to be).

Dim IE As Object

Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate ""

Do Until IE.ReadyState = 4: DoEvents: Loop

Sheets(1).Range("A1").Value = IE.document.Body.innerHTML

Open in new window

Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Call it this way from your code:

   PasteHTML Sheets(1).Range("A1"), IE.document.Body.innerHTML

Avatar of randys106


zorvek, your the man.  Thanks for the quick response.