2个我采用主要方法
1.word转为rtf格式后,richTextBox1.LoadFile(path)
2.生成一个word对象,复制其中内容,richTextBox1.Paste()

解决方案 »

  1.   

    引用的话,Microsoft.Office.Interop.Word,版本最好12.0.0.0以上
    第一种,转格式代码
    var ac = new ApplicationClass();
    ac.Documents.Open(source);
    ac.ActiveDocument.SaveAs(tempfile, WdSaveFormat.wdFormatRTF);
    ac.Documents.Close();
    Marshal.ReleaseComObject(ac);
    richTextBox1.LoadFile(tempfile)
    第二种,复制代码
    var ac = new ApplicationClass();
    var doc = ac.Documents.Open(task);
    doc.ActiveWindow.Selection.WholeStory();
    doc.ActiveWindow.Selection.Copy();
                            richTextBox1.Paste();
      

  2.   

    VSTO 这个时候能发挥完全作用。 
      

  3.   

    我这边正好做过,附上代码。using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.Threading;
    using Microsoft.Office.Interop.Word;private void button1_Click(object sender, EventArgs e)
            {
                        //调用打开文件对话框获取要打开的文件WORD文件,RTF文件,文本文件路径名称
                OpenFileDialog opd = new OpenFileDialog();
                opd.InitialDirectory = "c:\\\\";
                opd.Filter = "Word文档(*.doc)|*.doc|文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文档(*.*)|*.*";
                opd.FilterIndex = 1;            if (opd.ShowDialog() == DialogResult.OK && opd.FileName.Length > 0)
                {
                //建立Word类的实例,缺点:不能正确读取表格,图片等等的显示
                    ApplicationClass app = new Microsoft.Office.Interop.Word.ApplicationClass();
                    Document doc = null;
                object missing = System.Reflection.Missing.Value;            object FileName = opd.FileName;
                object readOnly = false;
                object isVisible = true;
                object index = 0;
                try
                {
                 doc = app.Documents.Open(ref FileName, ref missing, ref readOnly,
                  ref missing, ref missing, ref missing, ref missing, ref missing,
                  ref missing, ref missing, ref missing, ref isVisible, ref missing,
                  ref missing, ref missing, ref missing);             doc.ActiveWindow.Selection.WholeStory();
                 doc.ActiveWindow.Selection.Copy();
                 //从剪切板获取数据
                 IDataObject data=Clipboard.GetDataObject();
                 this.richTextBox1.Text=data.GetData(DataFormats.Text).ToString();
                 
                }
                finally
                {
                 if (doc != null)
                 {
                  doc.Close(ref missing, ref missing, ref missing);
                  doc = null;
                 }             if (app != null)
                 {
                  app.Quit(ref missing, ref missing, ref missing);
                  app = null;
                   }
                  }            }
            }
      

  4.   

    你会丢图片丢表格丢……等等
    RichTextBox自带了Paste()方法,基本不会丢东西,除非是RichTextBox无法显示的
      

  5.   

    图片和表格带过去也无意义吧?richtextbox显示出来也是乱码的。
      

  6.   

    你把这2句,直接改成this.richTextBox1.Paste();
    然后加载带图片的word自己试试看吧
      

  7.   

    RichTextBox本来就是丰富内容的TextBox,如果连图片这种都不能显示,不如直接用回TextBox吧
      

  8.   

    4楼Interop没有引用怎么解决?
      

  9.   

    错误 1 命名空间“Microsoft.Office”中不存在类型或命名空间名称“Interop”(是缺少程序集引用吗?) G:\123\123\Form1.cs 10 24 123
      

  10.   

    DLL是哪个引用?
    大哥你说清楚啊
      

  11.   

    是Microsoft.Office.Interop.Word,这个我贴的代码里已经很完整了。
      

  12.   

    你安装了完整了office2003/2007了吗?安装后才会有office相关的dll,注意是完整版。我碰到过精简版office不能引用的问题。
      

  13.   

    你会丢图片丢表格丢……等等
    RichTextBox自带了Paste()方法,基本不会丢东西,除非是RichTextBox无法显示的
    你把这2句,直接改成this.richTextBox1.Paste();
    然后加载带图片的word自己试试看吧
    这个可以~~
      

  14.   

    你会丢图片丢表格丢……等等
    RichTextBox自带了Paste()方法,基本不会丢东西,除非是RichTextBox无法显示的
    是个好方法!