I am trying to use MailMerge with Word from an Access 2007 (project) form, with tables in SQL. I have the following code:
Dim rsMM As ADODB.Recordset
Dim strSQLMM As String
strSQLMM = "Select * from dbo.xxx_LETTERS"
rsMM.Open strSQLMM, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Set rsMM = New ADODB.Recordset
conTemplate = "Y:\CVC USERS\nnnn\GroupLetters\documentName.dotx"
Set wrdApp = New Word.Application
Set Doc = wrdApp.Documents.Add(conTemplate)
With Doc.MailMerge
.OpenDataSource Name:=strSQLMM, _
LinkToSource:=True
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
etc.
etc.
But the code always hangs at the 'OpenDataSource Name' command. I have tried many variations and nothing seems to help. Any ideas? Thanks.
Dim rsMM As ADODB.Recordset
Dim strSQLMM As String
strSQLMM = "Select * from dbo.xxx_LETTERS"
rsMM.Open strSQLMM, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Set rsMM = New ADODB.Recordset
conTemplate = "Y:\CVC USERS\nnnn\GroupLetters\documentName.dotx"
Set wrdApp = New Word.Application
Set Doc = wrdApp.Documents.Add(conTemplate)
With Doc.MailMerge
.OpenDataSource Name:=strSQLMM, _
LinkToSource:=True
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
etc.
etc.
But the code always hangs at the 'OpenDataSource Name' command. I have tried many variations and nothing seems to help. Any ideas? Thanks.