Microsoft 365 Envoi document Excel en PDF par mail

rubis54

XLDnaute Occasionnel
Bonjour Tout le monde

J'ai un petit soucis avec ma macro qui envoie ma feuille "commande" par mail.

Alors elle me l'enregistre en pdf.

Lorsque j'appuis sur le bouton mail elle ouvre ma boite boite mail et on voit

que la pièce jointe en PDF est bien ma feuille "commande".

Ce que j'aurai souhaité c'est qu'au moment ou j'appuis le bouton mail,

qu'elle me laisse choisir le destinataire dans la liste en page données,

ou alors qu'elle le prenne en cellule "G3" de la feuille "commande",

qui est reliée via une "rechercheV au fournisseur" cellule "I2".

Alors est ce quelqu'un de vous pourrait bien m'aider à mettre ça en place SVP.

Je vous Remercie d'avance
 

Pièces jointes

  • ESSAI ENVOI MAIL.xlsm
    90.5 KB · Affichages: 9
Solution
Salut,
VB:
Sub EnvoiPDF()
  Dim Nom As String
  Nom = ActiveSheet.Name & ".pdf"
  ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    ActiveWorkbook.Path & "\" & Nom, Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    False
  Set olApp = CreateObject("Outlook.application")
  Set m = olApp.CreateItem(0)
  With m
    .to = ActiveSheet.[G3]
    .Attachments.Add ActiveWorkbook.Path & "\" & Nom
    .Display
  End With
End Sub

fanch55

XLDnaute Barbatruc
Salut,
VB:
Sub EnvoiPDF()
  Dim Nom As String
  Nom = ActiveSheet.Name & ".pdf"
  ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    ActiveWorkbook.Path & "\" & Nom, Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    False
  Set olApp = CreateObject("Outlook.application")
  Set m = olApp.CreateItem(0)
  With m
    .to = ActiveSheet.[G3]
    .Attachments.Add ActiveWorkbook.Path & "\" & Nom
    .Display
  End With
End Sub
 

rubis54

XLDnaute Occasionnel
Salut,
VB:
Sub EnvoiPDF()
  Dim Nom As String
  Nom = ActiveSheet.Name & ".pdf"
  ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    ActiveWorkbook.Path & "\" & Nom, Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    False
  Set olApp = CreateObject("Outlook.application")
  Set m = olApp.CreateItem(0)
  With m
    .to = ActiveSheet.[G3]
    .Attachments.Add ActiveWorkbook.Path & "\" & Nom
    .Display
  End With
End Sub
Salut Fanch55,
J'ai mis ton code en place et tout fonctionne.
Merci à toi.👍
 

Discussions similaires

Réponses
16
Affichages
431

Statistiques des forums

Discussions
311 721
Messages
2 081 929
Membres
101 843
dernier inscrit
Thaly