Merging an Access Database Table into a Word Document

G

Guest

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
 
J

John Nurick

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).

These links may help:
http://word.mvps.org/faqs/MailMerge/index.htm

Q209976 ACC2000: Using Automation to Run Word Mail Merge from Access
http://support.microsoft.com/?kbid=209976

Q209882 ACC2000: Using Automation to Create a Word 2000 Merge Document
http://support.microsoft.com/?kbid=209882
 

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