Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Mailmerge from vb.net

$
0
0
I have created an SQL database with a table called tblREP which has a single line of fields that I would now like to use to populate a microsoft word document.

In visual studio, I have created a button with the following code
        Dim w As New Word.Application
        Dim d As Word.Document
        Dim sqlstr As String
        sqlstr = "SELECT * FROM tblRep"
        d = w.Documents.Open("C:\...AIA.docx")
        Dim strConnection As String
        strConnection = "Data Source=*****\SQLEXPRESS;Initial Catalog=tree1;Persist Security Info=True;User ID=**;Password=******"
        d.MailMerge.OpenDataSource(strConnection, sqlstr)
        d.MailMerge.Execute()
        d.Close(False)
        w.Visible = True



However, I am getting this error:

This file could not be found.
(...\SQLEXPRESS;Initial Catalog=tree1;...)

Does anyone know where I am going wrong?

THanks
Frank

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>