Peter what you tel me is the thing i do daily 1 letter for 600 policy , but
i want this for 10 different letters , merge this 10 times is a lot of work
, i was trying to make a macro for it but I can't filter during de macro
because of de SQL statement , I can't say I want kolom 4 and filter on
number 4
my macro looks like this , i am using word 2003 , excel 2003 system xp
Sub Macro4()
'
' Macro4 Macro
' Macro opgenomen op 4 april 2005 door anton pc
'
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"F:\backup cd\excelbestanden\Map1\Map1.xls",
ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto,
_
Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data
Source=F:\backup cd\excelbestanden\Map1\Map1.xls;Mode=Read;Extended
Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet
OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLE" _
, SQLStatement:="SELECT * FROM `Blad1$`", SQLStatement1:="",
SubType:= _ XXXXX here i want to filter xxxxxxxx kolom 2 , number 4 or 5
or 6 or 7 ( letter number)
wdMergeSubTypeAccess
End Sub
> You must know how many different letters there are, so the easiest way is
> to construct the letters, set up your Excel sheet as the data source in
[quoted text clipped - 26 lines]
>>
>> we don't have MS Acces at our systems
Peter Jamieson - 05 Apr 2005 08:05 GMT
You need to put a different "WHERE" clause in the SQLStatement for each
merge. The "Subtype" parameter has a different function and is not well
documented.
For example, if you have a column called "Lettertype" in your Excel sheet
and it has values 1,2,3,4,5,6,7,8,9,10 depending on the letter, you could
use
SQLStatement="SELECT * FROM `Blad1$` WHERE Lettertype = 1"
in the first letter,
SQLStatement="SELECT * FROM `Blad1$` WHERE Lettertype = 2"
in the second letter, and so on. If Lettertype is a text field, you need to
put single quotes around the values, e.g.
SQLStatement="SELECT * FROM `Blad1$` WHERE Lettertype = 'A'"
Notice that these quotes are different from the ones around Blad1$.
You may also need to put quotes around Lettertype in some cases. These would
be the same type of quotes as you have around Blad1$.
You can /probably/ simplify your OpenDataSource to the following:
ActiveDocument.MailMerge.OpenDataSource Name := _
"F:\backup cd\excelbestanden\Map1\Map1.xls", _
Connection:= "", _
SQLStatement:="SELECT * FROM `Blad1$` WHERE Lettertype = 1"
However, I leave it to you to find out what actually works.
Peter Jamieson
> Peter what you tel me is the thing i do daily 1 letter for 600 policy ,
> but i want this for 10 different letters , merge this 10 times is a lot of
[quoted text clipped - 59 lines]
>>>
>>> we don't have MS Acces at our systems
anton - 05 Apr 2005 19:29 GMT
Thank you very much for your fast help
i wil try and let you now what will work
> You need to put a different "WHERE" clause in the SQLStatement for each
> merge. The "Subtype" parameter has a different function and is not well
[quoted text clipped - 94 lines]
>>>>
>>>> we don't have MS Acces at our systems