Bonjour,
j'ai un classeur excel à partir duquel je lance une macro avec variable sous word pour creer un pdf.
Du fichier word je voudrais ensuite lancer une macro avec variable dans le fichier excel deja ouvert (envoyer mail). c'est un peu alambiqué mais word 2007 à moins de possibilité de sendkey pour thunderbird.
j'ai écrit ce code mais il me dit erreur 1004 impossible d'excecuter la macro.
WORD avec les variables pour envoyer le mail
Excel
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 MsgBox "chemin fichier excel ouvert" & chemin MsgBox "nom fichier excel " & nomexcel GetObject(, "Excel.application").Workbooks(nomexcel).Application.Run "mailing", prenom, nom, mail, sujet, fichierjoint
Merci
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 Sub mailing(mail As String, sujet As String, fichierjoint As String, nom As String, prenom As String) Dim body As String body = "Bonjour " sujet1 = sujet & " " & nom & " " & prenom strcommand = "D:\PROGRAMMES\Thunderbird Original\Thunderbirdportable" fichierjoint = Replace(fichierjoint, "\", "/", 1, -1, vbBinaryCompare) strcommand = strcommand & " -compose " & "to='" & mail & "'" strcommand = strcommand & ",subject=&" & sujet1 & "'" strcommand = strcommand & "," & "attachment='file:///" & fichierjoint & "'" 'strcommand = strcommand & "," & "attachment='file:///" & fichierjoint1 & ",file:///" & fichierjoint2 & "'" strcommand = strcommand & ",body='" & body & "'" Call Shell(strcommand, vbNormalFocus) Application.Wait (Now + TimeValue("0:00:03")) SendKeys "^~", True 'SendKeys "%fd", True End Sub
PS: je voulais envoyer des mails de word 2007 au départ mais application.wait ne fonctionne pas et sendkeys non plus.....
Partager