Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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 |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Automated mail merge of catalog/directory inserts page breaks
Try setting the type of merge explicitly (i.e. to Directory), e.g. after the
OpenDataSource Peter Jamieson "Tim" wrote in message ... 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 |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Automated mail merge of catalog/directory inserts page breaks
Yes, that solves the problem. Thank you.
"Peter Jamieson" wrote: Try setting the type of merge explicitly (i.e. to Directory), e.g. after the OpenDataSource Peter Jamieson |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I mail merge to EMAIL from MS Word AND add a pdf attachment | Mailmerge | |||
30 page mail merge labels only prints one page? | Mailmerge | |||
How do I print 1 page of a mail merge? | Mailmerge | |||
Why do I get an extra page when I mail merge a word document? | Mailmerge | |||
section breaks change each time opening document | Microsoft Word Help |