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

New Topic/Question
Reply



MultiQuote




|