I'm trying to scrape a website for a specific HTML element and convert it into Word, all while keeping the formatting intact. I can successfully import it into Excel first (and then to Word), but the character limit for a single cell doesn't let me grab all of the data that I need. Here is my current code, starting at the point where I grab the HTML from the site:
Set html = ie.document
Dim objWord As Object
Dim objDoc As Object
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
objWord.Visible = True
Sheets("Sheet1").Range("A1").Value = html.getElementById("main_container").innerText
Sheets("Sheet1").Range("A1").Select
Selection.Copy
objDoc.Range.Paste
It would be great if I could skip the Excel step and just paste the HTML right into Word. The other option that I thought of is to paste each sub-paragraph of the main_container HMTL into a separate cell to avoid hitting the maximum character limit. If anyone can help with that, or has other ideas about how I can solve this, it would be much appreciated!
Cross-post here: http://www.mrexcel.com/forum/excel-questions/827926-hmtl-word-visual-basic-applications.html#post4039337