How to Automate Word mail merge from AC2007?

D

deko

I'm trying to do a Word mail merge from Access 2007 -- populating a
Word 2007 template with data from recordsets built off queries.

The problem I'm having is the current code creates each letter as a
separate Word doc. I need one big Word doc with page breaks between
each letter.

The code uses nested loops - the first recordset rst has the list of
people, the second rstBkm has bookmark data.

Question: How to get this code to create one Word doc with page breaks
between letters rather than each letter in a separate Word Doc?
Thanks in advance.

[abbreviated code below]

Set wordApp = New Word.Application

Do While Not rst.EOF 'recordset of individuals from Access

Set wordDoc = wordApp.Documents.Add(Template:=strTemplate,
NewTemplate:=False, DocumentType:=0)

rstBkm.MoveFirst

Do While Not rstBkm.EOF 'bookmarks to be populated
strBkm = rstBkm!FieldName
If (wordDoc.Bookmarks.Exists(strBkm)) Then
If strBkm = "Transactions" Then Call
GetTransactions(wordApp, wordDoc)
wordDoc.Bookmarks(strBkm).Select
wordApp.Selection.TypeText Text:=GetText(strBkm,
lngRid, lngEid)
End If
rstBkm.MoveNext
Loop

wordDoc.PrintOut

Loop
 

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