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.