Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Dim Dat As Variant, C As Range, Txt As String, Col As Integer
Dim L As Integer
Dim objOL As Object, ObjMail As Object
Dim oAttach As Object, ColAttach As Object
Set objOL = CreateObject("Outlook.Application")
Set ObjMail = objOL.CreateItem(0)
Set ColAttach = ObjMail.attachments
Set oAttach = ColAttach.Add("C:\Users\adv\Downloads\logo.jpg")
If Sh.Name <> "LIEN WAZE" And Sh.Name <> "Config" Then
Cancel = True
If Target.Value = "*" Then
If Target.Count > 1 Then Exit Sub
If Target.Column <> 20 Or Target.Row < 9 Then Exit Sub
Set olApp = CreateObject("Outlook.application")
With Sh
L = .[V:V].Find("*", , , , xlByRows, xlPrevious).Row + 1
Col = Application.Match("PLANNING D'INTERVENTION", .[6:6], 0)
For Each C In .Cells(9, Col).Resize(L, 5)
If C = .Cells(Target.Row, 1) Then
If .Cells(8, C.Column) < Dat Or Dat = "" Then
Dat = .Cells(8, C.Column)
End If
End If
Next C
End With
Txt = " <p> Bonjour, <p> Suite à notre entretien téléphonique je vous confirme le rendez-vous pour le début de votre chantier le <p> <b>"
Txt = Txt & "<dd>" & Format(Dat, "dddd dd/mm/yyyy") & _
" à partir de 7h30 </b> </dd> <p> A noter que nos poseurs sont habilités à réceptionner le chantier et à percevoir le solde restant dû, merci de " & _
"prendre vos dispositions afin que cela soit respecté à la fin des travaux. "
With ObjMail
.Subject = "Confirmation de rendez-vous"
.htmlBody = "<BODY><IMG src=cid:logo.jpg<\BODY>" & Txt
.Recipients.Add Target.Offset(, -1)
.display
End With
Set oAttach = Nothing
Set ColAttach = Nothing
Set ObjMail = Nothing
Set objOL = Nothing
End If
End If
End Sub