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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking a Word Mail Merge to a form via command Button

Status
Not open for further replies.

cs581

IS-IT--Management
Feb 27, 2002
3
US
I'm a newbie looking for advice. Anyone have any helpful suggestions for vb code to program a command button on click event to get data from a form to a mail merge in Word? It's not just labels I'm creating, but rather a letter related to an event, using fields on the form that are specific to the event shown. I saw a similar thread that used an IF statement, choosing 1 of 2 letters. I tried to modify that below. Any advice appreciated!

Private Sub cmdListingLetter_Click()
On Error GoTo Err_cmdListingLetter_Click

Dim objWord As Word.Document
Date = Now()
Set objWord = GetObject("c:\Path to my document here", "Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource_Name = "c:\Path to my database file as data source"
LinkToSource = True
Connection = "qryListingLetterMerge"

objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Application.Options.PrintBackground = False

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top