Peter-
It is a .dot When I open the macros it just says "MS Visual Basic" on
top,
so I am not sure if it is VB or VBA (how do I tell the difference?)
When I delete about 99% of the bottom of the template, then run the
mail-merge macros, I get only 1 copy. I'm trying to see at what point it
gives me a second copy of the document.
I thought that it was because I had a section break, but apparently this
is
not the cause.
Here is the code that produces the finished document:
WordBasic.MailMergeMainDocumentType 0
WordBasic.MailMergeOpenDataSource Name:="", ConfirmConversions:=0,
ReadOnly:=0, LinkToSource:=0, AddToMru:=0, PasswordDoc:="",
PasswordDot:="",
Revert:=0, WritePasswordDoc:="", WritePasswordDot:="",
Connection:="DSN=NCR-SQL;UID=sa;PWD=;APP=Microsoft
Query;WSID=SHIVAINDRA;LANGUAGE=us_english;DATABASE=lp_patents",
SQLStatement:="execute splp_lppci_US " & Chr(34) & OrderLetterNumber &
Chr(34), SQLStatement1:=""
WordBasic.MailMerge CheckErrors:=1, Destination:=0, MergeRecords:=0,
From:="", To:="", Suppression:=0, MailMerge:=1, MailSubject:="",
MailAsAttachment:=0, MailAddress:=""
Then I check some inputted variables to see if I need to delete any parts
of
the document:
If LPPCI0.AddedPages.Value <> True Then
With Selection
.HomeKey Unit:=wdStory
.Find.Execute FindText:="[transmittal]"
.ExtendMode = True
.Find.Execute FindText:="[added pages]"
.Delete
End With
End If
If LPPCI3.OptionButton17 <> True Then
With Selection
.HomeKey Unit:=wdStory
.Find.Execute FindText:="[added pages]"
.ExtendMode = True
.Find.Execute FindText:="[cover sheet]"
.Delete
End With
End If
With Selection
.HomeKey Unit:=wdStory
.Find.Execute FindText:="[transmittal]"
.ExtendMode = True
.Find.Execute FindText:="[transmittal]"
.Delete
End With
With Selection
.HomeKey Unit:=wdStory
.Find.Execute FindText:="[added pages]"
.ExtendMode = True
.Find.Execute FindText:="[added pages]"
.Delete
End With
With Selection
.HomeKey Unit:=wdStory
.Find.Execute FindText:="[cover sheet]"
.ExtendMode = True
.Find.Execute FindText:="[cover sheet]"
.Delete
End With
Thanks,
Marty
Peter Jamieson said:
Maybe you could spell out a few more things - e.g., is your "template" a
..dot or a .doc? Are the macros VB or VBA? What is "generating" the
document?
Are you talking about the process where you use File|New to create a new
document from a tempalte, or the process where you are performing a
mailmerge
It really isn't clear what you are doing and what you expect to happen as
a
result - remember, we can't see your template, its macros, and so on.
Peter Jamieson