View Single Post
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Tim Tim is offline
external usenet poster
 
Posts: 2
Default Automated mail merge of catalog/directory inserts page breaks

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