Bonjour,
J'utilise Excel 365 et comme messagerie Gmail
Je cherche donc à exporter une facture Excel en PDF (nous en avons une centaine à faire). Celle-ci s'enregistre dans Dropbox pour etre utilisée par d'autres utilisateur. A ce jour la facture s'exporte correctement. En revanche pour l'envoyer par mail sans Outloock c'est beaucoup plus compliqué malgré différents tuto. Une personne bienveillante pour aider notre association sportive est la bienvenue.
Concernant l'exportation de la facture Excel en PDF c'est tout bon. La facture s'enregistre avec le N° de facture + le nom du client dans un répertoire que je peux modifier
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 Sub EXPORTdaniel1_PDF() Dim Dossier Dim Chemin As String Dim ws As Worksheet Set ws = ActiveSheet If MsgBox(" Voulez vous exporter la facture en PDF ", vbYesNo + vbQuestion, "Confirmation .. ! ") = vbYes Then On Error Resume Next Dossier = Application.InputBox("Insérer nom du dossier", "Création du dossier", "Factures PDF") Chemin = ThisWorkbook.Path & "\" & Dossier & "\" Var = Dir(Chemin, vbDirectory) If Var = "" Then On Error GoTo 0 ChDir ThisWorkbook.Path MkDir ThisWorkbook.Path & "\" & Dossier End If ws.ExportAsFixedFormat xlTypePDF, Chemin & Range("E5").Value & " _ " & Range("L1").Value, _ xqualitystandard, True, False, 1, 1, False End If End Sub
Concernant l'envoi par mail, je coince bien, L'Email ne pars pas, j'ai fais un essai sans la PJ. Je ne vois pas non plus comment attacher la facture dans le mail
J'ai coché la case " Microsoft CDO for windows 2000 " dans les références dans VBA
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 Sub mail() Dim mail As CDO.Message Set mail = New CDO.Message mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = ?? mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/senusername") = "mon adresse mail@gmail.com" mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Mon Mot de passe@" mail.Configuration.Fields.Update With mail .Subject = "CSD Tennis de Table Facture" .From = "Mon adresse mail@gmail.com" .To = Sheets("Modele Facture").Range("L10").Value '.CC = « ***@*** » .TextBody = "Merci de recevoir votre facture relative à vos engagements. Cordialement" '.AddAttachement " de la pièce jointe" End With On Error Resume Next mail.Send Set mail = Nothing End Sub







Répondre avec citation
Partager