template appending to merged document

B

bidalah

Hello all,

I have automated a mail merge using vb.net. Not very easy, but I've
finally got it working with one exception. When the merge executes,
the new merge document that get created a copy of the template document
(minus the fields) is appending to the end of the merged document. I
get the form letter that I want and a copy of the template which I
don't. This happens whether I have the mailmerge print right out
(wesendtoprint) or create a new document (wdprintnewdocument). I can't
figure out what might be causing it.

Following is a portion of my code:

LetterDoc =
DataApp.Documents.Open("G:\imaging\Yooper\Sys\LetterGen_Letters\ACTLetters\"
& LetterList.SelectedItem, , , , , , , , , , False)

With LetterDoc
.MailMerge.MainDocumentType =
WdMailMergeMainDocType.wdFormLetters
.MailMerge.CreateDataSource(Name:=CurDir() &
"\datadoc.doc", _
HeaderRecord:="last_name,first_name,e_mail,id_number")
.MailMerge.EditDataSource()
DataApp.ActiveDocument.Tables.Item(1).Rows.Add()
End With

(I populate the table with relevent data here)

With LetterDoc
With .MailMerge
.Destination =
WdMailMergeDestination.wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
.Execute()
End With
End With

Again, this is working perfectly accept for the copy of the template
which appends to the end of my product. Any idea? Please let me know.
 
D

Doug Robbins

Do you happen to have a Next Record field at the end of the document that
becomes LetterDoc?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
B

bidalah

Hi Doug. Thanks for the response. I did not have a next record field
in my template letter. I did however have a blank row in the data
document (datadoc)! That was the problem. Mailmerge was working
perfectly, merging the row of data that I wanted and the blank fields
of the extra row.

Thanks again for your help.
 

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

Similar Threads


Top