Mail merge macro duplication

C

Curt

for some reason beyond me the following macro duplicates the data from the
text file when createing new document. I have removed the Selection.Type
Paragraph line to no avail where duplicated. Iam sending this to a new doc to
keep from printing till it works ok. the printing part is (') out from net
search.
Thanks for any help greatful

Sub Macro1()
' Macro recorded 5/31/2008 by Curtiss A. Greer
Selection.MoveDown Unit:=wdLine, count:=1
Selection.InsertDateTime DateTimeFormat:="MMMM d, yyyy", InsertAsField:= _
True, DateLanguage:=wdEnglishUS, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Selection.TypeParagraph
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
"Name_of_Entry"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
"Contact_Person"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
"Address"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:= _
"CityState"
Selection.TypeParagraph
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, Name:="Zip_"
Selection.TypeParagraph
Selection.TypeParagraph
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
'ActiveDocument.MailMerge.Destination = wdSendToNewDocument
'ActiveDocument.PrintOut Background:=False
'ActiveDocument.Close wdDoNotSaveChanges
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = False
With .datasource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
ActiveWindow.Close
CommandBars("Stop Recording").Visible = False
End Sub
 
D

Doug Robbins - Word MVP

For anything to be produced, the code that you have shown, must only be part
of what is being done as it does not set the mail merge main document type
or attach the data source.

As we cannot tell what else has been done to the document, one possible
reason that the data is being duplicated is because the fields that you are
adding by code were already in the document. Another possibility is that
you have run the macro twice on the same document and therefore added the
fields a second time.

Personally, I cannot understand why anyone would bother recording a macro
that performs those functions.

--
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
 
C

Curt

Right you are fields were in doc and I changed to another doc to see and
worked fine. Reason I am doing this way it is only I know how to keep word
merge going. The time taken to search excel spread sheet is covered by
creating a text file to merge from. I've tried useing a table etc to no
avail. Do not follow attach data source. I thought haveing macro get info
from text file was this. There is a lot I don't know as this is a venture for
me. This automates printing of letters by user.
Thanks much for the info
 

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

4198 debug 0
macro 2 issues 0
Word 2007 macro problem-different first page header 2
double merge 2
control print 2
merge search to long 2
word data from excel 0
macro stops 0

Top