MailMerge generating double-length document

D

Dean Slindee

Using VisualStudio 2008 with Word 2007 to generate a contract and 6
appendices from 7 separate Word documents.
The code loads the base contract into a new Word app. Then it appends 6
documents to the ActiveDocument. Then it does a mail merge with the
following code:
'perform mail merge
Call CreateMailMergeDataFile(wrdApp, wrdDoc)

Dim wrdMailMerge As Word.MailMerge
wrdMailMerge = wrdDoc.MailMerge
wrdMailMerge.Destination =
Word.WdMailMergeDestination.wdSendToNewDocument
wrdMailMerge.OpenDataSource(My.Settings.ModuleWorkPath &
"VendorContractMailMerge.doc")
wrdMailMerge.Execute(True)

Problem is, after the .Execute(True) statement, the mail merge is completed,
but what was a 23-page document becomes a 46-page document.
The first 23 pages have been successfully mail merged. The last 23 pages
are a duplicate of the first 23 pages, but with the mail merge fields
completely missing.

Anything I could do differently to prevent MailMerge from adding the
additional 23 pages?

Thanks in advance,
Dean Slindee
 
C

Cindy M.

Hi Dean,

Check the data source file whether it doesn't have a second (empty) record?

If this is a Word table, make sure there's not a third row (besides header row
and data row).

If this is a delimited text file, make sure there isn't an additional paragraph
following the data paragraph. Turning on the display of non-printing characters
will make this easier to determine. Only a single "backwards P" should follow
the data, not two (the second standing in its own "line").
Using VisualStudio 2008 with Word 2007 to generate a contract and 6
appendices from 7 separate Word documents.
The code loads the base contract into a new Word app. Then it appends 6
documents to the ActiveDocument. Then it does a mail merge with the
following code:
'perform mail merge
Call CreateMailMergeDataFile(wrdApp, wrdDoc)

Dim wrdMailMerge As Word.MailMerge
wrdMailMerge = wrdDoc.MailMerge
wrdMailMerge.Destination =
Word.WdMailMergeDestination.wdSendToNewDocument
wrdMailMerge.OpenDataSource(My.Settings.ModuleWorkPath &
"VendorContractMailMerge.doc")
wrdMailMerge.Execute(True)

Problem is, after the .Execute(True) statement, the mail merge is completed,
but what was a 23-page document becomes a 46-page document.
The first 23 pages have been successfully mail merged. The last 23 pages
are a duplicate of the first 23 pages, but with the mail merge fields
completely missing.

Anything I could do differently to prevent MailMerge from adding the
additional 23 pages?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
D

Dean Slindee

The mailmerge source table generated in code had an extra row at the bottom
where all cells were empty.
I was able to delete it, and the extra mailmerge copy disappeared.
Thanks for the hints, they helped a lot in narrowing down the source of the
problem.
 

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