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
> 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?
[quoted text clipped - 19 lines]
> > Thanks,
> > Marty
Peter Jamieson - 03 Aug 2006 21:18 GMT
> so I am not sure if it is VB or VBA (how do I tell the difference?)
From that description, it's VBA.
> 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.
From that description, my best guess is that there is some corruption in the
template. And that really is a guess. Does it contain a /lot/ of macros?
Perhaps more than your other templates that work? Either way, it may be
worth trying to reconstitute your template from scratch if possible. I think
you should be able to export the macros from the VB Editor and re-import
them in a new version of the template.
I don't think the code in your macro is particularly relevant - if it's
similar to the code in macros in your other documents then it's probably
irrelevant. But I'd be interested to know whether your other merge documents
all use an execute command in their OpenDataSource method call, and whether
they also use the WordBasic object or have been converted to native VBA.
(That may be a handful to answer, but do your best!)
Peter Jamieson
> Peter-
>
[quoted text clipped - 102 lines]
>> > Thanks,
>> > Marty