Error automating mail merge using access query

G

Guest

Hi all,

Using the code from article ID 209976 I am getting a complie error: sub or
function not defined when I test the code in the immediate window. Below is
the code which I have revised slightly. Can anyone tell me why I am getting
this error and what I need to do to fix it?

Function MergeItExp()

Dim objWord As Word.Document

Set objWord =
GetObject("G:\USER\Contracts\Data_Files\Access_Security\Expire_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:="G:\USER\Contracts\Data_Files\Access_Security\Contracts_Database.mdb", _
LinkToSource:=True, Connection:="QUERY Qry_Letters_BPV_ComplExpired", _
SQLStatement:="SELECT * from Qry_Letters_BPV_ComplExpired"
' Execute the mail merge.
objWord.MailMerge.Execute

End Function


Thank you
 
G

Guest

I don't know what the problem was but when I call the code from the click
event on my form it runs. Now I have another problem but i will Post under
seperate subject.
 

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