Automated mail merge of catalog/directory inserts page breaks

T

Tim

I created a Word mail merge document as a "Directory" (what used to be called
a "Catalog"). My data source is a tab-delimited text file. If I open Word and
merge manually, I get the results I expect: multiple records on a single
page. But if I use the ActiveX/.NET interface to run the same merge, I still
get the merged document, but it acts as if the merge was a "Letters" merge
instead of a "Directory" merge. That is, each record appears on its own page.

Here is the Visual Basic 2005 source code that runs the automation. It talks
to Word 2003 via the latest .NET PIA libraries talking through the Office
version 11.x ActiveX features.

<sourceCode>

Dim mergeDoc As Word.Document
Dim msWord As Word.Application
Dim workFile As String = "c:\temp\mergedata.txt"
Dim mergeTemplate As String = "c:\temp\mergecontent.doc"

' ----- Start up a connection to Microsoft Word.
msWord = New Word.Application
mergeDoc = msWord.Documents.Open(mergeTemplate, , True, False)
msWord.Visible = True

' ----- Perform the mail merge.
mergeDoc.MailMerge.OpenDataSource(workFile)
mergeDoc.MailMerge.Destination = _
Word.WdMailMergeDestination.wdSendToNewDocument
mergeDoc.MailMerge.Execute()

' ----- Finished with the main merge document.
mergeDoc.Close(False)

' ----- Finished.
msWord = Nothing

</sourceCode>
 
P

Peter Jamieson

Try setting the type of merge explicitly (i.e. to Directory), e.g. after the
OpenDataSource

Peter Jamieson
 

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