Re: Word 2003 VBA Mail Merge SQL filter of Excel data

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi Paul,

Take a look at the DataSource.QueryString property.

To get a feel for the syntax Word wants to use, record a macro while going
through the Recipients dialog box. Click on the arrow next to a field and choose
the "Advanced" option, which should bring up the Query Options dialog box. Set
the criteria there and that should record this property for you.

I succesfully created a Word 2003 VBA macro that will produce labels from all
the records in an excel workbook (by using the macro recorder and then
editing in a line stating "Application.MailingLabel.CreateNewDocument
Name:="L7160"").

To do this the MailMerge.OpenDataSource statement presently includes the
following SQL statements:
SQLStatement:="SELECT * FROM `LOG$` ", SQLStatement1:="",

NB "LOG" is the name of the Excel work*** in my workbook.

I need to be able to apply a filter for this mail merge so that only those
records that have a specific value (e.g. "27/02/07" in text or in Excel date
format) in the field that is headed "LOGDateOnly" are produced as labels.

After hours of internet searching and trials of possible SQL incantations I
now throw myself on the mercy of this forum.

Am I correct in searching for an SQL statement to achieve the filer? If so,
what can it be? If not, how can I achieve the Mail Merge Recipients
filtering capability?


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

.


Quantcast