打开word文档到richtextbox:
private void textBox1_MouseClick(object sender, MouseEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = "F:\\"; ofd.Filter = "Word文档(*.docx)|*.docx"; ofd.ShowDialog(); ApplicationClass app = new ApplicationClass(); Document doc = null; object missing = System.Reflection.Missing.Value; object FileName = ofd.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(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (doc != null) { app.Quit(ref missing, ref missing, ref missing); app = null; } } textBox1.Text = ofd.FileName; }