MailMerge from Access to Word

L

Lana

Hi all,

After i input all info into my DB using form, I need to output my record (1
at a time) from Access to Word template. Then i need to add some text, tables
etc. and save the file to a location.

i have created a mailmerge template already (called Letter.doc)
I found out that the below module code should automatically do the mailmerge
for me, same as if i would open a report for this record (but the Module is
not tested yet):

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\Documents and Settings\Lana\Desktop\Doc Control
DB Devlpmt\Letter.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Northwind database.
objWord.MailMerge.OpenDataSource _
Name:="E:\000-GL Folder Control\All Users\GLV Doc Control.mdb",
LinkToSource:=True, Connection:="TABLE Customers", SQLStatement:="SELECT *
FROM [qOutgoing] WHERE [ID]=Forms!CorrOutgoing!ID1"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function

Now i want to have a button on my form which would execute this module on
Click.
How do i do that? I know how to execute queries & macros - but this is a
Module...

Can anybody help me with a code please?

Thank you.
Lana
 

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