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.
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.
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.