Automatic Mail Merge

DentTec

Registered User.
Local time
Today, 12:12
Joined
Apr 3, 2011
Messages
25
Right now I click a button, which run a query of what addresses needed to be print. Then I have to open mail merge manually and print them from there. Is there a code allows me to print them right way (by pass merging manually)?
 
There is no simple way of doing this. Sure, you can write a module of code to do this but to provide that here would require a great deal more information from you. For example, you have not said anything about the format in which you would like these addresses to be printed, i.e. labels, envelopes, on a letter etc. Maybe post an example of the text layout e.g. do you want towns postcode, counties, countries etc. What are the fields available.

To automate the Mail Merge process requires a lot more information than you have provided.
 
Mail Merges can be done via VBA.

I have limited knowledge of them, but here's some example code from one of my old databases:

Code:
Dim db As Database
Dim s As Recordset
Set db = CurrentDb
Set s = db.OpenRecordset("qry_merge")
 
If s.RecordCount = 0 Then
   Dim rep
   rep = MsgBox("No Records found!", vbExclamation)
   Exit Sub
End If
 
Dim wd As New Word.Application, ltr As Word.Document
Set ltr = wd.Documents.Open("U:\BCC Macro\BCC4 CR CARD LETTER XP2.DOC", , , , , , , , , , , True)
wd.Visible = True
 
wd.ActiveDocument.MailMerge.OpenDataSource "U:\BCC Macro\VisionPLUS Macro.mdb", , , , False, , , , , , , "QUERY qry_merge", , , False
wd.ActiveDocument.MailMerge.Execute
 
ltr.MailMerge.MainDocumentType = wdNotAMergeDocument
ltr.Close True
 
db.Execute ("UPDATE TBL_MEMOS SET LETTER_BRANCH = TRUE WHERE MID(DATE_PROCESSED,1,10)='" & Mid(Forms!frm_date_report!List0.Value, 1, 10) & "'")
DoCmd.SetWarnings False
Echo True, "Merging Mail..."
wd.Visible = True
Set wd = Nothing

If nothing else this should give you a place to start! I'd begin by googling "ActiveDocument.MailMerge.OpenDataSource" to get all the arguements.

Some lines will be unrelated as they are editing a recordset to mark the mail merge as being complete for that record, etc.
 

Users who are viewing this thread

Back
Top Bottom