Bonjour à tous,
Question simple surement pour vous, mais un vrai casse-tête pour moi.
J'aimerai que dans le ".Body" ma variable se nommant Lien s'envoi au format lien hypertexte. J'ai tenté d'intégrer la fonction Hyperlinks comme vous pouvez le voir, mais il y a une incompatibilité dans la fonction visiblement. Somebody can help me please ?
Lien = ActiveSheet.Hyperlinks.Add Adress:= "M:\_COMMERCIAL\02 - Consultation\" & Range("I6") & "\Devis"
Voici mon 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 Lien As String
Dim OutApp As Object
Dim OutMail As Object
Dim S As Shape
Dim sNomFic As String, sRep As String, WshShell As Object
Feuil2.Activate
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Lien = ActiveSheet.Hyperlinks.Add Adress:= "M:\_COMMERCIAL\02 - Consultation\" & Range("I6") & "\Devis"
' 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 = Range("I6") & "- Matrice de conformité.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 = "XXXX"
.Cc = ""
.Attachments.Add (sRep & "\" & sNomFic)
.Subject = "Matrice de conformité - " & Range("I6")
.Body = "Bonjour," & vbCrLf & vbCrLf & "Veuillez trouver ci-jointe la matrice de conformité initiée sur la " & Range("I6") & "." & vbCrLf & "Merci de procéder à l'analyse via FORM231 suivant lien :" & vbCrLf & Lien & vbCrLf & vbCrLf & "Bonne journée." & vbCrLf & Range("K2")
.Display
.Send
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Kill (sRep & "\" & sNomFic)
Feuil1.Activate
End Sub