Bonjour, j'ai mis une macro pour envoyer en mail un PDF mais quand je clique sur le bouton pour envoyer le mail le document qui est en pièce jointe dans le mail est renommé avec des %20 exemple la capture écran. Pouvez vous me dire d'où vient le problème. Merci d'avance
Voici la macro :
Private Sub MAIL_Click()
Dim adresse_pro As String
Dim adresse_perso As String
Dim sujet As String
Dim texte As String
Dim lien As String
Dim Urlto As String
Dim doc As String
Dim numero As String
Dim avenant As String
Dim repertoire As String
Dim nom_fichier As String
Dim OlApp As Object
Dim olMailItm As Object
adresse_perso = Range("G1")
sujet = Range("c3")
texte = Range("C4")
numero = Range("F1")
avenant = ActiveSheet.Name
repertoire = ThisWorkbook.Path & "\"
nom_fichier = avenant & "-" & numero
doc = ThisWorkbook.Path & "\" & nom_fichier
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=doc, _
Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Set OlApp = CreateObject("Outlook.Application")
Set olMailItm = OlApp.CreateItem(0)
With olMailItm
.To = adresse_perso
.Subject = sujet
.body = texte
.attachments.Add doc & ".pdf"
.display
End With
'Urlto = "mailto:" & adresse_perso & "?Subject=" & sujet & "&Body=" & texte & lien & "&CC=" & adresse_pro & "&attachments=" & doc
'ActiveWorkbook.FollowHyperlink Address:=Urlto
Set olMailItm = Nothing
Set OlApp = Nothing
Kill doc & ".pdf"
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Voici la macro :
Private Sub MAIL_Click()
Dim adresse_pro As String
Dim adresse_perso As String
Dim sujet As String
Dim texte As String
Dim lien As String
Dim Urlto As String
Dim doc As String
Dim numero As String
Dim avenant As String
Dim repertoire As String
Dim nom_fichier As String
Dim OlApp As Object
Dim olMailItm As Object
adresse_perso = Range("G1")
sujet = Range("c3")
texte = Range("C4")
numero = Range("F1")
avenant = ActiveSheet.Name
repertoire = ThisWorkbook.Path & "\"
nom_fichier = avenant & "-" & numero
doc = ThisWorkbook.Path & "\" & nom_fichier
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=doc, _
Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Set OlApp = CreateObject("Outlook.Application")
Set olMailItm = OlApp.CreateItem(0)
With olMailItm
.To = adresse_perso
.Subject = sujet
.body = texte
.attachments.Add doc & ".pdf"
.display
End With
'Urlto = "mailto:" & adresse_perso & "?Subject=" & sujet & "&Body=" & texte & lien & "&CC=" & adresse_pro & "&attachments=" & doc
'ActiveWorkbook.FollowHyperlink Address:=Urlto
Set olMailItm = Nothing
Set OlApp = Nothing
Kill doc & ".pdf"
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Pièces jointes
Dernière édition: