Outlook application aide modification code
Bonjour, j'utilise un code qui me va super bien et j'aimerai l'améliorer et je n'y arrive pas.
Etant novice vba, j'append à déclarer les variables mais je maîtrise pas tout ...
1) A partir de ce code j'aimerai que dans le sujet la date celulle : "macelluledate" apparaissent après "voici mon sujet en date du "
2) Insérer dans le corps du message un texte prédéfinie " bla bla bla " en pouvant choisir la police et sa taille.
Sub envoyerMail()
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 = "nomfichier.pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sRep & "\" & Range("macelluledate").Value & "_" & 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 & "\" & Range("macelluledate").Value & "_" & sNomFic)
.Subject = "voici mon sujet en date du "
.Display
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Kill (sRep & "\" & Range("macelluledate").Value & "_" & sNomFic)
End Sub
Merci d'avance, cordialement.
bonjour,
voir ci-dessous pour l'ajout de la date dans le sujet et du texte blabla
pour choisir une police de caractères et une taille de caractère, il faudra utiliser la propriété .HTMLBODY et coder ton texte blabla avec les balises HTML qui vont bien.
Sub envoyerMail()
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 = "nomfichier.pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sRep & "\" & Range("macelluledate").Value & "_" & 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 & "\" & Range("macelluledate").Value & "_" & sNomFic)
.Subject = "voici mon sujet en date du " & Range("macelluledate").Value
.body = "bla bla bla "
.Display
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Kill (sRep & "\" & Range("macelluledate").Value & "_" & sNomFic)
End Sub
Merci beaucoup ça me convient parfaitement , je vais regardé côté html