Mail Merge VB.NET 2005 DataSet


  • Hi,

    I would like to perform a mail merge between VB.net 2005 and Word 2007 using a dataset from my application, so the user doesn't have to touch word they will just be presented with the mail merged data.

    I have already created my connection to SQL server and populated the dataset but how can I output the dataset to Word.

    I have looked on here and can only find information relating to vb6 not the .net framework examples.  I understand I will need to use Automation to achive this any documents or advice would be great.

    Many thanks

    Tuesday, July 03, 2007 7:20 PM


  • Rob_1982,


    Actually there are many resources on Mail Merge in .NET Framework. I would like to provide you an article in knowledge base that can help you with this kind of questions:


    How to automate Word to perform a mail merge from Visual Basic .NET




    Automation is a process that allows applications that are written in languages such as Visual Basic .NET to programmatically control other applications. Automation to Word allows you to perform actions such as creating new documents, adding text to documents, and formatting documents. With Word and other Microsoft Office applications, virtually all of the actions that you can perform manually through the user interface can also be performed programmatically by using Automation.


    Word exposes this programmatic functionality through an object model. The object model is a collection of classes and methods that serve as counterparts to the logical components of Word. For example, there is an Application object, a Document object, and a Paragraph object, each of which contain the functionality of those components in Word. To access the object model from Visual Basic .NET, you can set a project reference to the type library.


    This article demonstrates how to set the proper project reference to the Word type library for Visual Basic .NET and provides sample code to automate Word.


    You can also search in MSDN Forums by Mail Merge key words.


    Word MAil Merge Automation




    I've found a lot of threads on the issue. Thanks again for your question.


    Friday, July 06, 2007 6:05 AM