This project has moved. For the latest updates, please go here.

How to open and read word document

Dec 3, 2011 at 7:38 AM

Can someone please, post a code. how can i open and read word document using NetOffice.

 

thanks

Coordinator
Dec 3, 2011 at 1:49 PM
Edited Dec 3, 2011 at 1:49 PM

hello amer9264,

open and read a document in word is very easy and exactly the same as interop or VBA. here is sample in C#

// initialize NetOffice, must be called 1 times in your application before use
LateBindingApi.Core.Factory.Initialize();

// open word and an existing document
Word.Application wordApplication = new Word.Application();
Word.Document newDocument = wordApplication.Documents.Open(@"C:\myWordFile.doc");

// read text of document
string plainContent = newDocument.Content.Text;

// close word and dispose reference 
wordApplication.Quit();
wordApplication.Dispose();



NetOffice gives you a lot sample projects in C# and VB. checkout the examples folder in release package.
the most example code is also online available. an overview you find here:
http://netoffice.codeplex.com/wikipage?title=Word_ExampleOverview