MailMerge OpenDataSource

M

Max

Using Access 2003 (database format is 2003) and Word 2003, am trying to merge
a document from a list box to a table in the current database (table name is
MergeSource). It opens the word doc but brings up a dialog box asking me to
select a table. I thought I had specified the table in the OpenDataSource
statement. What am I doing wrong?

Have looked in the Help file, KB and on several web pages, but no luck.

Thanks in advance.


Dim WordApp As Object
Dim WordDoc As Object

Set WordApp = CreateObject("Word.Application")
Set WordDoc = WordApp.Documents.Open(strDirPath & Me.lstFiles & ".doc")
'Set objWord = GetObject(stMergeDoc, "Word.Document")
WordApp.Visible = True
'objWord.Application.Visible = True
WordDoc.MailMerge.OpenDataSource Name:=CurrentDb.Name, _
LinkToSource:=True, Connection:="TABLE MergeSource"

With WordDoc.MailMerge
.Destination = 0 ' 0 = new doc
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = 1
' .LastRecord = 1
End With
.Execute Pause:=True
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top