extract word into string

            string textreadinall;
            object nullobj = System.Reflection.Missing.Value;
            object docFalse = false;
            object docTure = true;
            object fofile = textBox1.Text;
            Word.Application wordApp = new Word.Application();
            Word.Document doc = new Word.Document();
            wordApp.Visible = true;
            doc = wordApp.Documents.Open(ref fofile, 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();
             textreadinall = data.GetData(DataFormats.Text).ToString();
             doc.Close(ref docFalse, ref nullobj, ref nullobj);
             wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);

posted @ 2010-01-17 17:09  greencolor  阅读(258)  评论(0编辑  收藏  举报