I use Visual Basic and an automation interface to retrieve strings from an external application. These strings contain simple html formatting codes (, , et
I'm using 2016. The only thing that worked was Range.InsertFile(path). Pasting Special didn't work.
AFAIK there is no builtin function to do that in VBA. You will have to write it yourself, which would be not too difficult if you restirct it to parse <b>, <i>, <a> and <p>,
for example. All other tags would have to be ignored.
Here's a link to add HTML to the clipboard using VB:
http://support.microsoft.com/kb/274326
Once you have the HTML on the clipboard, paste it into your word doc using something like this:
ActiveDocument.Range.PasteSpecial ,,,,WdPasteDataType.wdPasteHTML
This is pretty much the equivalent of you cutting and pasting it in manually.
Use InsertFile
Set objdoc = objInsp.WordEditor
Set objword = objdoc.Application
Set objsel = objword.Selection
objsel.WholeStory
vs_html = "<html><body>" + vs_body + "</body></html>"
vs_file = "C:\temp\1.html"
Call DumptoFile(vs_file, "", vs_html, False)
RetVal = objsel.InsertFile(vs_file, , , False, False)