Reputation: 11560
I have asked this question many time before with other questions. Never got answer.
Is there any way to get webdata with formatting and put it in microsoft word?
I got some solution based on this answer
HTML Text with tags to formatted text in an Excel cell
In My case I am getting data directly from web. Is there any direct process to get formatted HTML content.
My code is:
If .Hyperlinks.Count > 0 Then
HttpReq.Open "GET", .Hyperlinks(1).Address, False
HttpReq.send
oHtml.body.innerHTML = HttpReq.responseText
StrTxt = oHtml.getElementsByClassName("class").Item.innerHTML
With IE
.Visible = True
.navigate "about:blank"
.Document.body.innerHTML = StrTxt
.Document.execCommand "SelectAll"
.Document.execCommand "Copy"
End With
Set rng = Tbl.Cell(i, 1).Range
rng.Collapse wdCollapseStart
rng.PasteAndFormat wdPasteDefault
Set rng = nothing
End If
Is there any better way of doing this?
Upvotes: 0
Views: 601
Reputation: 25693
Since Word requires a converter to bring HTML into a Word document you basically have three choices:
"Better" is a matter of opinion and depends on what you mean by "better". Simplest is certainly what you're doing...
Upvotes: 1