C # Read Word

Source: Internet
Author: User

 private void Readfilecontent () {String path = @ "C:\Users\Lee\Desktop\TI cup design document \ Drip system \ Schedule progress. docx";            Object file = path;            Object nullobj = System.Reflection.Missing.Value;            Microsoft.Office.Interop.Word.Application wordapplication = new Microsoft.Office.Interop.Word.Application (); Microsoft.Office.Interop.Word.Document worddocument = wordApplication.Documents.Open (ref file, ref nullobj , Missing.Value, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref NULLOB            J, ref nullobj, ref nullobj, ref nullobj);            WordDocument.ActiveWindow.Selection.WholeStory ();            WordDocument.ActiveWindow.Selection.Copy ();            IDataObject data = Clipboard.getdataobject (); richTextBox1.Text = data. GetData (Dataformats.text).            ToString ();            Worddocument.close (ref nullobj, ref nullobj, ref nullobj); Wordapplication.quit (ref nulLobj, ref nullobj, ref nullobj); }



<pre name= "code" class= "CSharp" > private void Readfilecontent ()
{Microsoft.Office.Interop.Word.Application wordapplication = new Microsoft.Office.Interop.Word.Application (); Microsoft.Office.Interop.Word.Document worddocument; Object unknow = Type.Missing; Wordapplication.visible = false; String str = @ "C:\Users\Lee\Desktop\TI cup design document \ Drip system \ Schedule progress. docx"; object file = str; Worddocument = WordApplication.Documents.Open (ref file, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref UN Know, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow); for (int i = 1; i < WordDocument.Paragraphs.Count; i++) {String temp = Worddocument.paragraphs[i]. Range.Text.Trim (); Richtextbox1.appendtext (temp); Console.WriteLine (temp); } }



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

C # Read Word

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.