Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
jco
 
Posts: n/a
Default E-mail only records with e-mail adresses, snail mail the rest

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?
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default E-mail only records with e-mail adresses, snail mail the rest

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
"jco" wrote in message
...
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?



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
jco
 
Posts: n/a
Default E-mail only records with e-mail adresses, snail mail the rest

Thank you! This was helpful, I have now fixed it.

"Peter Jamieson" wrote:

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
"jco" wrote in message
...
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?




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merge does not include all records from list or Access table Doug Robbins - Word MVP Mailmerge 0 March 26th 06 11:54 PM
Envelope Mail Merge from .xls all records rather than selection Kara Mailmerge 3 February 7th 06 06:59 PM
Cannot edit Access records from Word mail merge toolbar button Snazbaz Mailmerge 2 January 24th 06 07:17 PM
Saving Mail Merge Records & also printing them. Glenn Mailmerge 4 September 2nd 05 02:12 PM
skipped mail merge records cls Mailmerge 1 April 28th 05 05:54 PM


All times are GMT +1. The time now is 09:23 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"