Oue mais ca va etre hardu car le code run un user form et ce la requete SQLstatement qui specifie quelle donnée importer!
Comment sur le fichier "double" je peux adapter une requete d'une macro ainsi que des conditions ecrite sur le fichier.
expl, la macro prend les donnee du mois date system et peux analyser le fichiers ^pour passer à la sequence suivante!!
à mon avis ce choo!
voila le code de la macro qui rapatrie la base avec la requete month!
Function fusion_master(month As String) As Boolean
'
' e_c_t Macro
' Macro enregistrée le 06/01/2006 par DENISE Louis
'
MyMonth_num = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" )
MyMonth_letter = Array("Janvier", "Fevrier", "Mars", "Avril", "mai", "Juin", "juillet", "Aout", "Septembre", "Octobre", "Novenbre", "Decembre" )
Const separateur As String = "/"
Const appos As String = "'"
Dim i As Integer
Dim MyDate
MyDate = Date
If month = "mois_anterieur" Then
i = 0
iret2 = Split(MyDate, separateur, -1, vbTextCompare)
mois = CInt(iret2(1))
fusion_master = True
Do
i = i + 1
Loop Until (CInt(MyMonth_num(i - 1)) = mois)
st = MyMonth_letter(i - 1)
X = "(Mois = " & appos & st & appos & " )"
ActiveDocument.MailMerge.OpenDataSource Name:= _
"I:\comptabilité matiière\liste_MASTER.xls", ConfirmConversions:=False, _
ReadOnly:=True, 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=I:\comptabilité matiière\liste_MASTER.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 `'Fichier Master$'` WHERE ((Type = 'A') AND " & X & " )" & "", SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
ElseIf month = "" Then
MsgBox ("veuillez sasir un mois" )
fusion_master = False
Else
X = "(Mois = " & appos & month & appos & " )"
fusion_master = True
ActiveDocument.MailMerge.OpenDataSource Name:= _
"I:\comptabilité matiière\liste_MASTER.xls", ConfirmConversions:=False, _
ReadOnly:=True, 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=I:\comptabilité matiière\liste_MASTER.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 `'Fichier Master$'` WHERE ((Type = 'A') AND " & X & " )" & "", SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
End If
End Function
voila!