如何在保留格式的同时使用Visual Basic将HTML格式化字符串插入Microsoft Word文档? [英] How do I insert HTML-Formatted Strings into a Microsoft Word Document using Visual Basic while preserving formatting?

查看:183
本文介绍了如何在保留格式的同时使用Visual Basic将HTML格式化字符串插入Microsoft Word文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Visual Basic和一个自动化界面从外部应用程序中检索字符串。这些字符串包含简单的html格式代码(< b> ;,< i>等)。
在Visual Basic for Word中,是否有任何简单的函数可以将这些字符串插入到word文档中并将html格式代码转换为word格式?

解决方案

http://support.microsoft.com/kb/274326



在剪贴板上放置HTML后,将它粘贴到word文档中,使用如下所示:

  ActiveDocument.Range.PasteSpecial ,,,, WdPasteDataType.wdPasteHTML 

这与您手动剪切和粘贴相当。

I use Visual Basic and an automation interface to retrieve strings from an external application. These strings contain simple html formatting codes (<b>, <i>, etc.). Is there any easy function in Visual Basic for Word to insert these strings into a word document and convert the html formatting codes to word formatting?

解决方案

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.

这篇关于如何在保留格式的同时使用Visual Basic将HTML格式化字符串插入Microsoft Word文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆