XL 2016 comment envoyer fichier excel en pièce jointe

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

OIiv109

XLDnaute Nouveau
Bonjour à tous,

J'ai une macro dans mon fichier excel qui envoi par mail via outlook la feuille excel en pdf renommée selon cellules.

Par contre je voudrais faire la même cchose mais l'envoyer en excel et non pdf, mais je ne trouve pas.

Merci à tous ceux qui peuvent m'aider

Ci-dessous macro :
Sub Mail()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
Dim S As Shape
Dim sNomFic As String, sRep As String, WshShell As Object, LeNom As String

LeNom = Range("O13").Value

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

' Créer une instance Windows Script pour retrouver le chemin du bureau
Set WshShell = CreateObject("WScript.Shell")
sRep = WshShell.SpecialFolders("Desktop")
Set WshShell = Nothing
' Définit le nom du fichier à enregistrer
sNomFic = LeNom & ".pdf"
' Enregistrer la feuille en PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sRep & "\" & sNomFic, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False

Set OutApp = CreateObject("outlook.application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = Range("O17").Value
.Cc = ""
.Attachments.Add (sRep & "\" & sNomFic)
.Subject = Range("A1") & " : " & Range("F9") & " - Cde : " & Range("F15") & " - Réf : " & Range("F13") & " - Client commissionné : " & Range("O15") & " - Montant commission : " & Range("F27").Value & " €" & " H.T"
.Display
End With

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Kill (sRep & "\" & sNomFic)
End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
4
Affichages
360
  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
247
Réponses
2
Affichages
403
  • Question Question
Microsoft 365 Code VBA
Réponses
7
Affichages
636
Retour