Mail Merge problem - Word cannot open data source

dglover

New member
Local time
Today, 08:53
Joined
Jan 25, 2007
Messages
3
Hi All,

When I perform a mail merge to my template word document, it works ok 1st time round, then fails 2nd time round.

Word seems to lose its connection with my database after the following code is run;

Code:
Me.VersionTextBox.SetFocus
strVersion = Me.VersionTextBox.Text

Dim objWord As Word.Document
Set objWord = GetObject("c:\Template.doc", "Word.document")
objWord.MailMerge.OpenDataSource _
Name:="C:\ReleaseDetailsRef.mdb", _
LinkToSource:=True, _
Connection:="TABLE DiskReleaseTable", _
SQLStatement:="SELECT * FROM [DiskReleaseTable] Where Version = '" & strVersion & "'"
objWord.MailMerge.Execute
objWord.Application.Visible = True
objWord.Close

Has anyone come across this problem before, or any ideas what might be wrong? Any help would really be appreciated.

Many thanks in advance

Dave
 

Users who are viewing this thread

Back
Top Bottom