I am using VBA to create a mail merge document in Word from a data source on SQL Server. Currently I have to create a pass through query in Access. How would I go about doing this directly to SQL Server?
In the code below I set up then exceute the mailMerge on the ActiveDocument.
Where
= an reference to an open MS Word application
= the name of the pass through query in Access
= a string holding the full Access Database Name + Path
Idealy I could use the line
to reference the SQL Server directly?
I have been trying to use the
argument of the
property of the
object to give the path of the SQL Server or a DSN, which points to the SQL Server, but I do not know the correct syntax or if this is even possible? Another idea, would I be able to use an ADO.Connection?
Things work as they are (if a little slow). Thanks in advance to anyone who gives this some thought, I'll post a solution if I devise one in the meantime.
Best Regards
Belch
martin.Belcher@pegs .com
In the code below I set up then exceute the mailMerge on the ActiveDocument.
Code:
With appwd.ActiveDocument.mailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:=strDatabase, _
Connection:="query qryMailMerge"
.Destination = wdSendToNewDocument
.Execute
End With
Where
Code:
appwd
Code:
qryMailMerge
Code:
strDatabase
Idealy I could use the line
Code:
.OpenDataSource
I have been trying to use the
Code:
Connection
Code:
.OpenDataSource
Code:
mailMerge
Things work as they are (if a little slow). Thanks in advance to anyone who gives this some thought, I'll post a solution if I devise one in the meantime.
Best Regards
Belch
martin.Belcher@pegs .com