views:

70

answers:

2

I'm currently using Visual Studio 2010 Professional, and noticed the ability to create Word 2007 and Word 2010 documents as add-ins with C#.

What I'm looking to do is fill in a report-type document with information in my C# application, and then output the final .docx. Is this possible using this feature, and how do I go about doing it?

+4  A: 

What you're seeing is called VSTO (Visual Studio Tools for Office). It's a way to create and manage client-instantied add-ins, templates and documents (or, as some do, just control the client for particular operations). It comes with a lot of overhead.

It sounds like what you want instead is the Open XML SDK 2.0. This will give full access to creating Word (and other Office) documents without any need for the Word client or the VSTO requirements (VSTO runtime, Primary Interops, etc.) for the program or on the OS that is creating them. There is a great deal of information out there on the OpenXML SDK - a good starting point is http://www.openxmldeveloper.org. Another, is How-To videos.

Otaku
+1 for Open XML, this has worked well for us
Shiraz Bhaiji
+1  A: 

Will,

I have used MS Word's Content Controls for this purpose. Works better than BookMarks (multiple controls with same name can be populated, unlike bookmarks where repeating data has to have unique bookmark names).

Here is a nice walk-through / tutorial on how to do this step by step using Word 200, C#, ASP.Net (sample code also in there)

Shiva