Reply
 
Thread Tools Display Modes
  #1   Report Post  
 
Posts: n/a
Default template appending to merged document

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\Lett erGen_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_numb er")
.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.

  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

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
wrote in message
oups.com...
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\Lett erGen_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_numb er")
.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.



  #3   Report Post  
 
Posts: n/a
Default

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.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Merge to New Document Template Association Al Mailmerge 2 June 2nd 05 09:11 AM
CPU Usage When Working with Templates you created KM1 Microsoft Word Help 3 May 21st 05 11:57 PM
Template selector for SharePoint document libraries Daniel Microsoft Word Help 1 April 23rd 05 03:40 PM
Corrupt fonts when printing a merged document Mark J Barefoot Mailmerge 3 March 20th 05 08:17 PM
How to add additional copies of template to document Jim Cant Mailmerge 3 February 22nd 05 12:29 AM


All times are GMT +1. The time now is 10:42 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"