je ne comprends rien du tout
ça veut dire quo définir une plage ?
en ce qui concerne les onglets, la macro doit transformer en PDF toujours l'onglet visible actif. Il n'y a pas quelque chose de plus simple qu'une boucle ?
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
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 = Sheets("nom onglet").Range("A1").Value & ".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 = Sheets("nom onglet").Range("C8").Value (destinataire du mail selon adresse écrite dans cellule C8 de l'onglet actif)
.Cc = "xyz@gmail.com"
.Attachments.Add (sRep & "\" & sNomFic)
.Subject = Sheets("nom onglet").Range("A1").Value
.Display
End With
OutMail.send
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Kill (sRep & "\" & sNomFic) (effacer le fichier pdf de là où il a été sauvegardé, une fois qu'il a été joint à l'email et envoyé.)
End Sub