tags:

views:

55

answers:

3

Hi.. How to create, edit or save a word file using c#.net. Plz suggest me the libraries and necessary tools needed to work on Word files. I need solutions for the below questions:

How to access and read and interpret word[.doc] files in .net? How Code is to be intergrated onto the source file? How to represent this word file in a standard format? Suggest me some related web sites. Also if source code of such similar projects on word.

Thank You in Advance!

+2  A: 

You need to reference Microsoft.Office.Interop.Word to access the relevant types and methods. If you have access to C# and .NET 4 the syntax is a lot nicer, than it used to be from C#.

E.g. to open word you need to do something along these lines

     var word = new Word.Application();

     word.Documents.Add();
     Document = word.Documents[1];

     word.Visible = true;

For more info, please check the documentation.

Brian Rasmussen
+1  A: 

Starting from Word 2007, word documents can be saved as Open Xml. You can use the Open Xml SDK to edit/save/etc...

Even more info:
Open Xml Scenarios
Intro to Word XML
Word Xml format walkthrough

StephaneT
A: 

Aspose.Words is a decent tool. It's a great API if you're doing enterprise development but it might be a little pricey if you're just working on some pet projects at home (there's a free download with an unlimited evaluation period -- you only need a license for deployment). For casual/home development, I'd recommend Microsoft's OpenXML SDK (if you only need to support 2007 or beyond) or you could always use automation via the Interop assemblies.

Patrick