Hi guys, I found the solution.
You let excel open the word file.
Set wordapp = CreateObject("word.Application")
wordapp.documents.Open
"Path word file"
Then you give an IF command for the selected receiver:
If CB_Rec.Value = "receiver 1" Then
After that you place a recorded macro for the merging and the printing:
ActiveDocument.Shapes.Range(Array("Text Box 2")).Select
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"Path for the selected excel list"
, ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
Connection:= _
"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=
Path for excel list, (no double quotes)
;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Lockin" _
, SQLStatement:="SELECT * FROM
`SheetName
$`", SQLStatement1:="", SubType:= _
wdMergeSubTypeAccess
With ActiveDocument.MailMerge
.Destination = wdSendToPrinter
.SuppressBlankLines = True
With .DataSource
.FirstRecord = 1
.LastRecord = 1
End With
.Execute Pause:=False
End With
End If
You can choose the row for data you want to use:
I chose for receiver 1:
1
For receiver 2 you choose:
2
!!! My excel file contains Headers !!!
Hope I can help others with this solution for my problem.
Bookmarks