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