Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MailMerge automation from Access VBA headache

Status
Not open for further replies.

Dilettant

Technical User
Sep 27, 2006
16
US
Am using the following code. Actually it is more complex because it allows user's choice of both envelope size and address list, but I first want to make it work the simple way.

Code:
Private Sub MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject(CurrentFolder & "Envel#10.doc")
objWord.Application.Visible = True
With objWord.MailMerge
    .MainDocumentType = wdFormLetters
    .OpenDataSource Name:=CurrentFolder & "ChipsSoftware.mdb", _
        linktosource:=True, Connection:="Query QEnvelAll"
    .Destination = wdSendToNewDocument
    .Execute (True)
    .DataSource.Close
End With
End Sub

It launches Word, opens the main document but then presents a "Select Table" dialog box. Selecting the query QEnvelAll and clicking OK will complete the merger but I want it to be fully automatic since the user doesn't know what a query is. Why doesn't it accept the connection parameter of opendatasource? Am I doing something wrong? Thanks for any help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top