Mail merge to MS Word

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
 
G

Guest

This is a fairly common problem, with a couple of solutions. If you desire to use the DDE method you've described below, do the following.

1) Rename your application to start with "Microsoft Access." This could be "Microsoft Access LettersDatabase," or whatever. It just has to start with "Microsoft Access" to give DDE a chance of finding your open application in the task bar.

2) Only have one copy of MS Access open. If DDE finds multiple instances, voila, it opens another copy. Isn't it great?

David Atkins, MCP
 

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