October 1, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Using Visual Studio Tools for Office in Visual Studio 2008

  • April 28, 2008
  • By M. Rajesh
  • Send Email »
  • More Articles »

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.

For simplicity, you will start with a custom Word template, which is seen in Figure 1. This is mapped to a XML scheme and the tags can be seen in the template.



Click here for a larger image.

Figure 1: The XML tags in the invite letter that will replace the invite’s 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.



Click here for a larger image.

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).



Click here for a larger image.

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



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel