Bonjour,
J'ai cherché dans plusieurs sujets postés et plusieurs forums un moyen d'envoyer un tableau par PDF via Outlook. Après toutes ces recherches, la formules la plus adaptées à mon besoin est celle-ci :
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 = "classeur1.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 = ""
.CC = ""
.Attachments.Add (sRep & "\" & sNomFic)
.Subject = ""
.body = ""
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Kill (sRep & "\" & sNomFic)
End Sub
Cette formule a parfaitement fonctionné et puis, sans raison valable, du moins pour moi, elle a cessé de fonctionner.
Quelqu'un saurait-il me dire si j'ai modifié par inadvertance quelque chose ?
A savoir, je ne maitrise pas du tout le langage VBA.
Je remercie d'avance les personnes qui se pencherons sur mon problème.
bien à vous,
Ben