Platform: Access 2003 SP2 and Windows XP.
I've tried a number of different scenarios and none of them seem to work
The "OpenDataSource" statement gives a Run-time error 5922. Please help find my error.
'********************************************
Dim wdApp As Word.Application, wd As Word.Document, strConnection As String
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = False
xPathDoc = "C:\Documents and Settings\BDA Software\LienWaiver.doc"
Set wd = wdApp.Documents.Open(xPathDoc, , True)
Dim wdMM As Word.MailMerge, strSourceFile As String
Set wdMM = wdApp.Documents(xPathDoc).MailMerge
With wdMM
.MainDocumentType = wdFormLetters
.OpenDataSource Name:="C:\Documents and Settings\BDA Software\Database.mdb", _
LinkToSource:=True, _
Connection:="TABLE tblLienWaiver", _
Sqlstatement:="SELECT * from tblLienWaiver"
.Destination = wdSendToPrinter
.SuppressBlankLines = False
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute 'Pause:=False
End With
Set wdMM = Nothing
wd.Close wdDoNotSaveChanges
wdApp.Quit
Set wdApp = Nothing
Exit Sub
' *********************************
Thank you, Willis