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
|
Private Sub Op3_Click()
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
'ouverture de la session Word
Set WordApp = New Word.Application
'ouverture du document Word
Set WordDoc = WordApp.documents.Open("C:\Documents and Settings\CLAS\Base.doc")
'Word est visible pendant l'opération
WordApp.Visible = True
'Recherche des champs de fusions dans le fichier source
ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Documents and Settings\CLAS\Compte CLAS.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=C:\Documents and Settings\CLAS\Compte CLAS.xls;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Je" _
, SQLStatement:="SELECT * FROM `Adhé$Print_Area`", SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
'sauvegarde les modifications
WordDoc.Save
End Sub |