Click here to Skip to main content
15,885,366 members
Articles / Database Development / SQL Server
Article

Creating CSV from SQL Database table attaching it to MS word as datasource and then creating mailmerge document

Rate me:
Please Sign up or sign in to vote.
3.00/5 (7 votes)
2 Jul 2008CPOL 45.7K   1.6K   33   2
Creating CSV from SQL Database table attaching it to MS word as datasource and then creating mailmerge document

Sample Image - Mailmerge.jpg

Introduction

The code is devided into three parts
1) Creating CSV file
2) Opening CSV file
3) Using CSV file to mailmerge with word document

1) Creating CSV File

CSV file is created from the database table and the file is saved on c: with file name test1.csv.

2) Opening CSV File

This will open the csv file created in step one. It is opened in excel.

3) Mailmerge with word document

For this you will have to first create a word document that will used for merging and save it on c:\ with file name test.doc. The code attach the datasource of test1.csv file to test.doc and also adds field name to word document from datasource.

For using this code you will need to reference of Word and Excel to your project.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionAnother DOCX mail merge solution Pin
Johnny Glenn13-Mar-12 23:33
Johnny Glenn13-Mar-12 23:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.