Mailmerge Automation

nathangoldhill

Registered User.
Local time
Today, 00:29
Joined
Aug 6, 2001
Messages
12
I have set up an automatic mail merge to run using a parameter query. The problem is that when i do it automatically using the code below it crashes with a doctor watson. The weird thing is if i do it manually from word it works. I have also set it up using dde instead of obdc and it still also opens another instance of access.
Any ideas?

Cheers Nathan. (Code See below)

Function MergeIt3()
Dim objWord As Word.Document
Set objWord = GetObject("y:\stats database\notices.doc", "Word.document")
' Make Word Visable.
objWord.Application.Visible = True
'set the mail merge data source as statstatus#2 database
objWord.MailMerge.OpenDataSource _
Name:="y:\stats database\statstatus#2.mdb", _
LinkToSource:=True, _
Connection:="QUERY notice", _
SQLStatement:="Select * from [notice]"
' Execute the mailmerge.
objWord.MailMerge.Execute
End Function
 
Try renaming and eliminating the space between your directory "stats database" and see if this works.

Access does not like spaces when calling directories or file names outside of its environment at times.
 

Users who are viewing this thread

Back
Top Bottom