日期:2014-05-17 浏览次数:20400 次
Word.ApplicationClass wordApp=new ApplicationClass();
object file=path;(//译注:这个path是函数的参数,表示Word的路径)
object nullobj=System.Reflection.Missing.Value;
Word.Document doc = wordApp.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);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data=Clipboard.GetDataObject();
txtFileContent.Text=data.GetData(DataFormats.Text).ToString();
doc.Close();
//从数据中取的流转换为doc文档。在根据路径取的内容。
FileStream fsWrite = new FileStream(@"F:\2.docx", FileMode.Create, FileAccess.Write);
fsWrite.Write(b, 0, b.Length);
fsWrite.Close();
fsWrite.Dispose();
string path = @"F:\2.docx";
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
object file = path;
object nu