How do I insert HTML-Formatted Strings into a Microsoft Word Document using Visual Basic while preserving formatting?

前端 未结 4 1351
臣服心动
臣服心动 2021-01-02 15:42

I use Visual Basic and an automation interface to retrieve strings from an external application. These strings contain simple html formatting codes (, , et

4条回答
  •  佛祖请我去吃肉
    2021-01-02 16:14

    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.

提交回复
热议问题