View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default how do I stop unwanted entries to filter in mail merge?

If using VBA does not cause problems for you, can you try setting up
your data source using the following code:

Sub setupdatasource()
Dim strDSPath as String
' Put your Excel sheet's pathname in he
strDSPath = "c:\myxls\myxl.xlsx"
With ActiveDocument.MailMerge
' uncomment the next line if necessary
'.MainDocumentType = wdNotAMergeDocument
.OpenDataSource _
Name:=strDSPath, _
sqlstatement:=" SELECT * FROM [Sheet1$]" & _
" WHERE [Contact Name] is null OR [Contact Name] = ''"
End With

End Sub

Peter Jamieson

http://tips.pjmsn.me.uk

Paullyie wrote:
Hi Doug,

Not sure if this is directly the same, But I have a similar issue
Using office 2007, I have a letter mail merge in Word looking to Excel DB.
One of my filters is set to
FIELD: Contact Name
COMPARISON: 'IS BLANK'

This filter does not apply correctly.
It returns all rows whether Contact Name is Blank or contains a value.

Have trawled through various forums, not many answers, but few forums have
mentioned this is a bug with Word 2007.

Like above I was able to make a workaround and populate the Blank fileds
with a single value, and filter based on that value.

Just wondering is there a fix for this?

Thanks in Advance
Paul
-----------------------------------------------------------------------
"Doug Robbins - Word MVP" wrote:

Set up a column in Excel with a formula that returns a specific value for
the combination that you want to filter on and then filter on that column.

Forget about using the AddressBlock and just insert the mergefields that you
want to use in the configuration that you want them.

Also , see "Formatting Word fields with switches" on fellow MVP Graham
Mayor's website at:

http://www.gmayor.com/formatting_word_fields.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"John" wrote in message
...
When filtering my Excel DB for envelopes, I choose a column and put "is
not
equal to" "0"; it works fine. Then I add an "and" 2nd option to look at a
different column for not equal to No. When I choose OK, I get more
envelopes
than I had with only the one search argument. A return to filter shows
that
a 3rd condition has been added, 2nd column is blank. Nothing I've tried
will
get rid of the automatic entry.

What am I doing wrong?

Another problem I had with this MM is the address block; Word would not
match my 5+4 Zip code to their Postal code. I finally got rid of my +4 so
I
could proceed. Ideas?