Bonjour tout le monde
Mon code a été conçu avec microsoft excel 97-2003 il marchait super bien et là on est sur microsoft 2010
quand je lance ma macro publipostage il ne marche que sur une seule machine les autres machines il m'affiche (l'objet demandé n'est pas disponible ) c'est à cause de l'intruction .Destination = wdSendToPrinter
est ce qu'il y'a une personne qui a rencontré ce probleme j'arrive pas a trouver la solution aidez moi svp cet urgent merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 Sub Publiposter() 'Macro de lancement rattachée au bouton 'On définit les chemins Dim CheminAbo As String Dim mesFichiers As String Dim fusion_excel As String CheminAbo = ActiveWorkbook.Path + "\..\Courriers4\" 'On lance le bousin Dim Fichier As String mesFichiers = Dir(CheminAbo + "\*.doc") Do While mesFichiers <> "" 'Compteur pour imprimer deux fois counter = 0 If (Left(mesFichiers, 2) > "00" And Left(mesFichiers, 2) < "28") Then 'vérification du préfixage 'Imprimer le courrier en 2 exemplaires Do While counter < 2 Imprimer_Courrier CheminAbo, mesFichiers, fusion_excel counter = counter + 1 'MsgBox counter Loop End If mesFichiers = Dir Loop End Sub Private Function Imprimer_Courrier(ByVal Repertoire As String, ByVal NomDoc As String, ByVal NomExcel As String) 'Application.DisplayAlerts = True Dim oWordApp As Word.Application Dim oDoc As Word.Document Set oWordApp = CreateObject("Word.Application") oWordApp.Visible = False Set oDoc = oWordApp.Documents.Open(Filename:=Repertoire & "\" & NomDoc) With oDoc.MailMerge 'Spécification de fusion vers l'imprimante' ignorer .Destination = wdSendToPrinter ' <<<<<<<<<<<<<<<<<<<<<<< ================ ICI ====<<<<< .SuppressBlankLines = True With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With 'Exécute l 'opération de publipostage .Execute Pause:=True End With oDoc.Close 'True oWordApp.Quit End Function
Partager