F
Frank
I'm using MS Access to do a mail merge. The mail merge
works fine except that when the below code executes it
also opens the source database. How do I stop
the "LetterDatabase.mdb" from also opening?
THANKS IN ADVANCE!
Public Sub sMergeToMSWord(LetterName As String)
Dim objWord As Word.Document
Set objWord = GetObject(LetterName, "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Letters
database.
objWord.MailMerge.OpenDataSource _
Name:=LetterDatabase, _
LinkToSource:=True, _
Connection:="TABLE SelectedLetters", _
SQLStatement:="SELECT * FROM
[SelectedHighroadLetters]"
' Execute the mail merge.
objWord.MailMerge.Execute
objWord.Close
End Sub
works fine except that when the below code executes it
also opens the source database. How do I stop
the "LetterDatabase.mdb" from also opening?
THANKS IN ADVANCE!
Public Sub sMergeToMSWord(LetterName As String)
Dim objWord As Word.Document
Set objWord = GetObject(LetterName, "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Letters
database.
objWord.MailMerge.OpenDataSource _
Name:=LetterDatabase, _
LinkToSource:=True, _
Connection:="TABLE SelectedLetters", _
SQLStatement:="SELECT * FROM
[SelectedHighroadLetters]"
' Execute the mail merge.
objWord.MailMerge.Execute
objWord.Close
End Sub