It depends what you mean by "merge". You can use Word's Database field
to include data from Access as a table in Word; Word's mailmerge
feature can use an Access table as its data source. If you want to
control the process from Access, start with Albert Kallal's sample
mailmerge application: http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html
The question is; "How can I setup the merge document to with merge field code
to import the access database table."
This my access code below.
Dim objWord As Word.Document
' Dim objWord As Object
Dim strDocName As String
Dim strDatabaseName As String
strDocName = CurrentProject.Path & "\MergeLetter.doc"
Set objWord = GetObject(strDocName, "Word.Document")
' Set objWord = GetObject("MergeLetter.doc", "Word.Document")
'
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Northwind database.
objWord.MailMerge.OpenDataSource _
Name:=strDatabaseName, _
LinkToSource:=True, _
Connection:="QUERY qryFormletter"
'SQLStatement:="SELECT * FROM tblCustomerProfile"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function
I still don't really understand what you're trying to do. If you want
to import a database table into a Word document, use Word's DATABASE
field. If you want to create a form letter using Word's mailmerge, the
usual way is to create the letter in Word's user interface, inserting
merge fields wherever needed, and then run the merge itself from Access
(e.g. with code like that in Albert Kallal's sample application which I
pointed you to earlier).
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.