1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
Sub Publipostage()
'
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Set WordApp = CreateObject("word.application")
WordApp.Visible = True
Set WordDoc = WordApp.Documents.Open("M:\GE2.docx")
WordApp.DisplayAlerts = wdAlertsNone
WordDoc.MailMerge.OpenDataSource Name:="M:\GE.xlsm" _
, 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=M:\GE.xlsm;Mode=Read;Extended Properties=""HD" _
, SQLStatement:="SELECT * FROM `'fr-FR$'`", SQLStatement1:="", SubType:= _
wdMergeSubTypeAccess
With WordDoc.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute
End With
WordApp.Windows("Lettres types1").Activate
WordApp.ActiveDocument.SaveAs "M:\toto.doc"
WordApp.ActiveDocument.Close
WordDoc.Close
WordApp.Quit
End Sub |
Partager