Using Visual Studio Tools for Office in Visual Studio 2008
A sample application using VSTO
Now, you will do a walkthrough with Visual Studio to create a mail merge document so that the user can generate mailers on the fly from a custom data pane. This data pane will be mapped to a database; the user can flick through the records and then print out the document if he wants. Of course, he can return to the application any time to take the printout if he wants.
For this, you will be using Visual Studio 2008 and Office 2007. You will make use of a custom Word Template and the Document Pane in Office 2007. Note that the same can also be done using VSTO with Visual Studio 2005. Because VSTO is build into Visual Studio 2008, this makes it easier to start working.
Figure 1: The XML tags in the invite letter that will replace the invites name and address from the database.
Note that you can see the XML tags in the document as follows. This is to indicate that these are the columns in the database. Take a customer table and refer it from a sample database named PartyInvite.
To, [First Name] [Last Name] [Street Address] [City], [State] [ZIP Code] Dear [First Name],
Now, you will have to integrate this document with a VSTO application so that it is mapped to the table. When the document opens, you will see the screen, as shown in Figure 2.
Figure 2: The final output of the document after you complete this walkthrough.
To start with, fire up Visual Studio 2008 and select New Project. Then, select the Office 2007 category on the left side and then from the right side, select Word 2007 template (see Figure 3).
Figure 3: The pop-up dialog in Visual Studio 2008 that allows you to create a Word template based on the .NET 3.5 Framework.
Page 2 of 7