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 / February 2004

Tip: Looking for answers? Try searching our database.

MailMerge destination document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex - 16 Feb 2004 10:33 GMT
Hi everyone

I've created a mailmerge template for my work colleges
that when opened automatically runs the following code.

Sub autonew()
   With ActiveDocument.MailMerge
       .Destination = wdSendToNewDocument
       .MailAsAttachment = False
       .MailAddressFieldName = ""
       .MailSubject = ""
       .SuppressBlankLines = True
       With .DataSource
           .FirstRecord = wdDefaultFirstRecord
           .LastRecord = wdDefaultLastRecord
       End With
       .Execute Pause:=True
   End With
End Sub

However, end users being end users, they still aren't
satisfied, so I hope you guys can help.

Requirements:
The macro must run on Word 97, 2000, XP and 2003
The Full Recipient list will always be merged into the
document

Problem with Current Code:
Even though the current code does all the hard work for
them, they don't like the fact that it produces two
documents, The document with MailMerge fields and the
Merged document.

I've been through the VBA object model and the only
destination options appear to be:

1. wdSendToNewDocument
2. wdSendToFax
3. wdSendToEmail
4. wdSendToPrinter

So the question is, is there any way via VBA to force word
to merge the recipient list data into the first document
created by Word, that way only one document is produced
instead of two.

A big thank you in advance

Alex
Peter Jamieson - 17 Feb 2004 07:08 GMT
Try something more like:

Sub autonew()
Dim oMainDocument As Word.Document
Set oMainDocument = ActiveDocument
   With oMainDocument.MailMerge
       .Destination = wdSendToNewDocument
' I don't think you need the following
'        .MailAsAttachment = False
'        .MailAddressFieldName = ""
'        .MailSubject = ""
       .SuppressBlankLines = True
       With .DataSource
           .FirstRecord = wdDefaultFirstRecord
           .LastRecord = wdDefaultLastRecord
       End With
       .Execute Pause:=True
   End With
   oMainDocument.Close savechanges:=wdDoNotSaveChanges
End Sub

--
Peter Jamieson - Word MVP
Word MVP web site http://word.mvps.org/

> Hi everyone
>
[quoted text clipped - 46 lines]
>
> Alex
Alex - 17 Feb 2004 12:26 GMT
Thanks Peter

That worked great.

Alex

>-----Original Message-----
>Try something more like:
[quoted text clipped - 74 lines]
>
>.
 
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.