如何将Microsoft Word中的文本导入vb.net? [英] How can I import text that is in Microsoft word to vb.net?

查看:110
本文介绍了如何将Microsoft Word中的文本导入vb.net?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Microsoft Word中的文本导入vb.net中的文本框?

how can I import text that is in Microsoft word to a textbox in vb.net????????

推荐答案

此搜索应该提供什么您正在寻找:

Google [ ^ ]



请在发布问题之前重新发布指南。
This search should provide what you are looking for:
Google[^]

Please red the guidelines before you post a question.


使用的方法取决于文档的格式(doc或docx)以及目标计算机上是否安装了Word。 />


如果安装了Word,您可以使用 Word Interop 并且不用担心文档的格式。



如果格式为docx,则可以使用 Open XML SDK 打开文件并阅读它。
The method used depends on document''s format (doc or docx) and whether or not Word is installed on the target machine.

If Word is installed, you can use Word Interop and not worry about the document''s format.

If the format is docx, then you can use the Open XML SDK to open the file and read it.


添加对 Microsoft.Office.Interop.Word 程序集的引用,然后尝试:

Add a reference to the Microsoft.Office.Interop.Word assembly, then try this:
Dim wordApp As New Microsoft.Office.Interop.Word.Application()
Dim doc As Document = wordApp.Documents.Open("D:\Temp\MyDoc.docx")
Dim s As String = doc.Content.Text

然后您可以将文本放在哪里你喜欢!

You can then put the text where you like!


这篇关于如何将Microsoft Word中的文本导入vb.net?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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