需要安装Word,导入引用,选择Com类型,导入Office对象库,Word对象库(注意版本),using对应的命名空间,就可以显示Word了。即使使用WebBrowser,如果本机没有安装Word,一样不能正确处理复杂格式的Word文档。

解决方案 »

  1.   

    WebBrowser  可以的  
      

  2.   

    这要看楼主的word文档的复杂性
      

  3.   


    WebBrowser webBrowser1 = new WebBrowser();
    webBrowser1.Url = @"c:\1.doc";SuspendLayout();
    this.Controls.Add(webBrowser1);
    ResumeLayout();
      

  4.   

       /*
                 * 
                 * 要操作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);