tags:

views:

1011

answers:

3

Hi I would like to open a word in c #. I mean I would like to know how a word document is embedded in c# I found some article in the net and I have question. What does it mean here: Open Word Application, and Add New. If I open the Word I don't see any "add new" is that in C#? I'm using Microsoft Visual Studio 2008. Thanks

All the methods used Word automation is derived either from Word.Application or Word.Document class.

Let's consider that we want to create a document using the Word Application, we might end up doing the following steps,

Open Word Application. (Opening Word Application creates a new document by default, but in Automation, wee need to manually add a document)
Add a New document.
Edit the document.
Save it

regards C# NewBie

=========

you can find the article here by the way: http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx and I would like to clear it out, that this is not a homework.

+7  A: 

I tended to find the Open XML SDK much better to create Word documents with, as it doesnt require an instance of Word or Excel.

Open XML Format SDK V1

Open XML Format SDK V2

Version 2 is much much better than version 1.

Moo
thanks I'll give it a try
tintincute
A: 

One good trick to see how a document is built up is to go to File > Save As > Xml Document. This is how I learned to build out excel files on the fly, and I'm sure it works just fine for Word as well. I'm using office 2003 so I'm not sure if that save feature exists, but I konw that the excel documents I create are compatible with 2007.

ScottE
A: 

As above.

Aslo, I've done quite a bit of driving Office applications using .NET. My advice is if you know VB refactor the library into a VB.NET DLL. VB.NET supports optional parameters and late binding unlike C#, which makes it much easier for automating office.

Conrad
Hi Conrad, that's the problem I don't have any background in VB. this is my first language programming.
tintincute