Bonsoir François,
C'est parfait !! Merci beaucoup, par contre j'ai voulu copier ta macro et la modifier pour exporter en PDF puis préparer par mail.
Seulement je n'y suis pas parvenu. je pensais utiliser le code ci après mais ça ne prépare que 1 seule feuille par mail au lieu des 2 (BE-044) et (BE-042).
Pourtant le principe est le même que pour l'export en PDF seul, non ?
Encore un grand merci ! :)
JB
Sub Rectangle1_Cliquer()
Dim i As Long, nom As String, chemin As String
' Créer une instance Windows Script pour retrouver le chemin du bureau
Set WshShell = CreateObject("WScript.Shell")
sRep = WshShell.SpecialFolders("Desktop")
Set WshShell = Nothing
For i = 4 To Range("A" & Rows.Count).End(xlUp).Row
If IsEmpty(Range("H" & i).Value) Then
If Range("I" & i).Value >= 30 Then
nom = Range("A" & i).Value
' Définit le nom du fichier à enregistrer
sNomFic = nom & ".pdf"
' Enregistrer la feuille en PDF
Sheets(nom).ExportAsFixedFormat Type:=xlTypePDF, Filename:=sRep & "\" & sNomFic, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Set OutApp = CreateObject("outlook.application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<BODY> feuille EXCEL préparée par mail </BODY>"
With OutMail
.Display
.To = ""
.Cc = ""
.Attachments.Add (sRep & "\" & sNomFic)
.Subject = "BE n° " & nom
.HtmlBody = strbody & .HtmlBody
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Kill (sRep & "\" & sNomFic)
Application.DisplayAlerts = False
sup = Sheets.Count
Sheets(sup).Delete
Application.DisplayAlerts = True
End If
End If
Next
End Sub