Macro language for filter

R

Ricki Miles

I am creating a Word XP macro to create an automated mail merge. I need the
merge to happen only for reocords with an exact match to a certain field
(example DEPT = 3). After I record the macro choosing to filter on the
field during the merge, the language in the macro does not mention the
nature of the match. What is the proper macro language to make this happen?

TIA,

Ricki
 
P

Peter Jamieson

If you define a filter in the MailMerge Recipients dialog or its "advanced"
facility, Word actually "translates" your filter specifications into an SQL
SELECT statement. Precisely how it does it depends on which dialect of SQL
it thinks it needs to use. But toset up the filter in code,
a. find out the SQL that WOrd is using (e.g. look at the value of
ActiveDocument.MailMerge.DataSource.QueryString)
b. either set ActiveDocument.MailMerge.DataSource.QueryString to have the
value you need or
c. set the valuein a cal to OpenDataSource (you may have to do it this way
if you cannot use approach (b).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top