Bonjour
Je souhaite editer des etats en passant par word et comme vous l'avez deja dit je suis alle " chez raymond pour prendre le code du publipostage"
J'ai donc mi ce code sous le click d'un bouton
Mon probleme est un message d'erreur sur la 3eme ligne
W_App As New Wors.Application
me disant "Erreur de Compilation" "type defini par l'utilisation non defini"
Ci joint le code
Merci d'avance pour votre aide
Private Sub Commande55_Click()
On Error Resume Next ' a modifier selon besoin
Dim W_App As New Word.Application
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Strsql As String
Set Db = CurrentDb
Strsql = "SELECT Clients.Client_N°, Clients.Client_Nom, Clients.Client_Rue, "
Strsql = Strsql & "Clients.Client_Ville, Clients.Client_CodePostal, Clients.Client_Adresse, "
Strsql = Strsql & "Clients.Client_Suivi_Mensuel "
Strsql = Strsql & " FROM Clients "
Strsql = Strsql & " WHERE (((Clients.Client_Suivi_Mensuel)=Yes));"
Set Rs = Db.OpenRecordset(Strsql)
If Rs.BOF Then GoTo Exit_Sub
With W_App
.Visible = True
Do Until Rs.EOF
.Documents.Open ("c:doc1.doc")
.ActiveDocument.Bookmarks("nom").Select
.Selection.InsertAfter Rs.Fields("client_nom")
.ActiveDocument.Bookmarks("rue").Select
.Selection.InsertAfter Rs.Fields("client_rue")
.ActiveDocument.Bookmarks("postal").Select
.Selection.InsertAfter Rs.Fields("client_codepostal")
.ActiveDocument.Bookmarks("adresse").Select
.Selection.InsertAfter Rs.Fields("client_adresse")
.ActiveDocument.PrintOut False
.ActiveDocument.Close wdDoNotSaveChanges
Rs.MoveNext
DoEvents
Loop
End With
Exit_Sub:
Rs.Close
Set Rs = Nothing
Set Db = Nothing
W_App.Quit
Set W_App = Nothing
End Sub |