object nullobj = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word._Application myWordApp = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document doc = null;
try
{
//本地文件存放位置
object file = defile + this.comboBox1.Text;
doc = myWordApp.Documents.Open(ref file, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject();
Microsoft.Office.Interop.Word._Application myWordApp = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document doc = null;
try
{
//本地文件存放位置
object file = defile + this.comboBox1.Text;
doc = myWordApp.Documents.Open(ref file, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject();
string content = data.GetData(DataFormats.Text).ToString();
}
catch (Exception ex)
{
}
finally
{
//关闭文档
doc.Close(ref nullobj, ref nullobj, ref nullobj);
//退出word应用程序
myWordApp.Quit(ref nullobj, ref nullobj, ref nullobj);
}