Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / August 2006

Tip: Looking for answers? Try searching our database.

additional copy of document is generated

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marty - 03 Aug 2006 19:38 GMT
Hi-

I have a mailmerge template in Word2003 which uses MS Visual Basic macros.
These macros ask for data input which is used to populate the template. After
the document is generated, there is a second copy. Why am I getting 2
documents?

I have other similar templates which work correctly by producing only 1
document.

Thanks,
Marty
Doug Robbins - Word MVP - 03 Aug 2006 19:59 GMT
It is not possible to tell without your showing us the code that is being
run.

Signature

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

> Hi-
>
[quoted text clipped - 9 lines]
> Thanks,
> Marty
Peter Jamieson - 03 Aug 2006 20:00 GMT
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
> Hi-
>
[quoted text clipped - 9 lines]
> Thanks,
> Marty
Marty - 03 Aug 2006 20:42 GMT
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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.