Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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 | |
|
|
![]() |
||||
Thread | Forum | |||
Merge to New Document Template Association | Mailmerge | |||
CPU Usage When Working with Templates you created | Microsoft Word Help | |||
Template selector for SharePoint document libraries | Microsoft Word Help | |||
Corrupt fonts when printing a merged document | Mailmerge | |||
How to add additional copies of template to document | Mailmerge |