sergiofox
XLDnaute Junior
Bonjour le forum, J'ai un code vba pour envoyer un feuille excel en pdf via Outlook à la maison, j'ai chercher pour utiliser la messagerie par défaut car certains utilisateur n'ont pas Outlook, j'ai tenter plusieurs formules avec CDO mais rien ne fonctionne? Pourriez-vous m'aider ?
le code que j'utilise
le code que j'utilise
Code:
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
Set WshShell = CreateObject("WScript.Shell")
sRep = WshShell.SpecialFolders("Desktop")
Set WshShell = Nothing
sNomFic = [M4] & " - " & [C6] & " - " & [J6] & Format(Date, " dd-mm-yyyy") & " " & Format(Time, "hh'mm") & ".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 = [C36] & ";" & [J36] & ";" & [Q36]
.Attachments.Add (sRep & "\" & sNomFic)
.Subject = "Feuille de match BWBC"
.Display
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Kill (sRep & "\" & sNomFic)
End Sub
Dernière édition: