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 / March 2006

Tip: Looking for answers? Try searching our database.

E-mail only records with e-mail adresses, snail mail the rest

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jco - 29 Mar 2006 18:39 GMT
I have a database where some names (records) have e-mail adressese and others
don't (they only have snail mail adresses). Using mail merge I would like to
make a procedure that sends the letter as an e-mail to those who have the
e-mail adress registered, while the rest are sent to the printer for posting.
The procedure should be as automatic as possible, preferrably only one click
to do both.

Any suggestions to how this could best be solved?
Peter Jamieson - 29 Mar 2006 19:44 GMT
You will need a macro that does two merges. Each merge will need to be able
to select the appropriate records - that may or may not be easy, depending
on the data source and whether it is easy to test whether a record should be
e-mailed or printed . For example, if the data source is Access, it may make
sense to create a query that selects the "e-mail" records and a query that
selects the "printer" records.

If you want to use the same mail merge main document for both merges (which
may or may not be a good idea depending on whether you are sending the
document as an attachment or plain text), you can probably do it using a
macro that does something along the following lines:

With ActiveDocument.MailMerge
' The following statement disconnects and existing data source
' and discards filters and sorts
 .MainDocumentType = wdNotAMergeDocument
 .MainDocumentType = wdFormLetters
 .Destination = wdSendToEmail
' You will need to adapt the following to your data source. One way to find
out
' what is needed is to record a macro while setting up a data source, then
' look at the values of ActiveDocument.MailMerge.Name, .ConnectString and
.QueryString
' In Word 2002 you may not be able to do that, so save the document in HTML
format then
' reopen it in Notepad and have a look for the mail merge block near the
top.
' You may need to check WHERE [myemailfield] IS NOT NULL as well

' There is no subtype parameter in Word 2000 and earlier
 .OpenDataSource _
 Name:="c:\mydata\mydb.mdb", _
 SQLStatement:="SELECT m.* FROM [mytable] WHERE [myemailfield] <> ''", _
 SubType:=wdMergeSubTypeAccess
 .Execute

' You may not need the following two lines
 .MainDocumentType = wdNotAMergeDocument
 .MainDocumentType = wdFormLetters
 .Destination = wdSendToPrinter

' You will need to adapt the following to your data source as well.
' In some cases you may instead be able to change the Query string
successfully
' by setting .QueryString, e.g.
' .QueryString = "SELECT m.* FROM [mytable] WHERE [myemailfield] =''"

 .OpenDataSource _
 Name:="c:\mydata\mydb.mdb", _
 SQLStatement:="SELECT m.* FROM [mytable] WHERE [myemailfield] =''", _
 SubType:=wdMergeSubTypeAccess
 .Execute

Peter Jamieson
>I have a database where some names (records) have e-mail adressese and
>others
[quoted text clipped - 8 lines]
>
> Any suggestions to how this could best be solved?
jco - 29 Mar 2006 22:00 GMT
Thank you! This was helpful, I have now fixed it.

> You will need a macro that does two merges. Each merge will need to be able
> to select the appropriate records - that may or may not be easy, depending
[quoted text clipped - 62 lines]
> >
> > Any suggestions to how this could best be solved?
 
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.