怎么在C#的form界面中导入word?急求。谢谢 需要安装Word,导入引用,选择Com类型,导入Office对象库,Word对象库(注意版本),using对应的命名空间,就可以显示Word了。即使使用WebBrowser,如果本机没有安装Word,一样不能正确处理复杂格式的Word文档。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 WebBrowser 可以的 这要看楼主的word文档的复杂性 WebBrowser webBrowser1 = new WebBrowser();webBrowser1.Url = @"c:\1.doc";SuspendLayout();this.Controls.Add(webBrowser1);ResumeLayout(); /* * * 要操作Word,我们就需要Word的对象库文件“MSWORD.OLB”(word 2000为MSWORD9.OLB), * 通常安装了Office Word后,你就可以在office安装目录的Office10文件夹下面找到这个文件, * 当我们将这个文件引入到项目后,我们就可以在源码中使用各种操作函数来操作Word。 * 具体做法是打开菜单栏中的项目>添加引用>浏览,在打开的“选择组件”对话框中找到MSWORD.OLB后按确定即可引入此对象库文件, * vs.net将会自动将 库文件转化为DLL组件,这样我们只要在源码中创建该组件对象即可达到操作Word的目的! * */ if (this.openFileDialog1.ShowDialog() == DialogResult.Cancel) return; string path = this.openFileDialog1.FileName; if (path.Length < 1) return; Word.ApplicationClass wordApp = new Word.ApplicationClass(); object MyFileName = path ; object Nothing = System.Reflection.Missing.Value; Word.Document doc = wordApp.Documents.Open(ref MyFileName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing); doc.ActiveWindow.Selection.WholeStory(); doc.ActiveWindow.Selection.Copy(); IDataObject data = Clipboard.GetDataObject(); richTextBox1.Text = data.GetData(DataFormats.Text).ToString(); doc.Close(ref Nothing, ref Nothing, ref Nothing); C# 中如何设置快捷键 高手们来看看啦 ComboBox 相关 哪位大侠哥哥帮我把下面这个乱码转换啦。 指针问题,在线等待 c#如何搞一个工具条,当用户下载安装后就能实现在IE下方的工具条,类似GOOGLE工具条这样的. C#中如何得到字串地址? 怎样在C#中形成树结构??~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~在线= SerialPort控件接受数据错误,而VB中的Mscomm控件接受的数据正常 新手提问 关于API 函数调用的问题?忠于C#的朋友们请进!!! C#排序算法大全 有做验证码识别的吗? 进来帮个忙,谢谢了
WebBrowser webBrowser1 = new WebBrowser();
webBrowser1.Url = @"c:\1.doc";SuspendLayout();
this.Controls.Add(webBrowser1);
ResumeLayout();
*
* 要操作Word,我们就需要Word的对象库文件“MSWORD.OLB”(word 2000为MSWORD9.OLB),
* 通常安装了Office Word后,你就可以在office安装目录的Office10文件夹下面找到这个文件,
* 当我们将这个文件引入到项目后,我们就可以在源码中使用各种操作函数来操作Word。
* 具体做法是打开菜单栏中的项目>添加引用>浏览,在打开的“选择组件”对话框中找到MSWORD.OLB后按确定即可引入此对象库文件,
* vs.net将会自动将 库文件转化为DLL组件,这样我们只要在源码中创建该组件对象即可达到操作Word的目的!
* */ if (this.openFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
string path = this.openFileDialog1.FileName;
if (path.Length < 1)
return;
Word.ApplicationClass wordApp = new Word.ApplicationClass(); object MyFileName = path ; object Nothing = System.Reflection.Missing.Value; Word.Document doc = wordApp.Documents.Open(ref MyFileName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
doc.ActiveWindow.Selection.WholeStory(); doc.ActiveWindow.Selection.Copy(); IDataObject data = Clipboard.GetDataObject(); richTextBox1.Text = data.GetData(DataFormats.Text).ToString(); doc.Close(ref Nothing, ref Nothing, ref Nothing);