1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| Sub Rdv()
'
' Macro3 Macro
'
'
Dim derl As Integer
Dim i As Integer
Dim heure As Date
Dim jours As Date
Dim depart As Date
Dim objet As String
Dim debmatch As Date
Dim finrdv As Date
derl = Range("b" & Rows.Count).End(xlUp).Row
For i = 11 To derl
If Cells(i, 2) > 0 Then
heure = Cells(i, 3)
jours = Replace(Replace(Replace(Replace(Cells(i, 2), "samedi ", ""), "dimanche ", ""), " ", "/"), " ", "/")
depart = jours + heure
objet = Cells(3, 6) & " : " & Cells(i, 5) & " - " & Cells(i, 6)
debmatch = Cells(i, 4)
finrdv = jours + Cells(i, 4) + CDate("01:00:00")
'-----------------------------
Dim OutlApp As New Outlook.Application
Dim OutlMapi As Outlook.Namespace
Dim OutlFolder As Outlook.MAPIFolder
Dim OutlAppointment As Outlook.AppointmentItem
Dim OutlItems As Outlook.Items
Dim DateDebut As String
Set OutlMapi = OutlApp.GetNamespace("MAPI")
Set OutlFolder = OutlMapi.GetDefaultFolder(olFolderCalendar)
Set OutlItems = OutlFolder.Items
On Error Resume Next
Set OutlAppointment = OutlItems.Find("[start] = '" & depart & "'")
On Error GoTo 0
'----- si pas de rendez vous a la date indiquée -------
If OutlAppointment Is Nothing Then
'-----------------------------------
Dim OkApp As New Outlook.Application
Dim Rdv As Outlook.AppointmentItem
Set Rdv = OkApp.CreateItem(olAppointmentItem)
With Rdv
.MeetingStatus = olMeeting
.Subject = objet
.Body = Cells(i, 1) & Chr(10) & "-début du match : " & debmatch & Chr(10) & Chr(10) & Chr(10) & Chr(10) & "-* entraineur : " & Cells(4, 3) & Chr(10) & "-* numéro entraineur : " & Cells(5, 3) & Chr(10) & "-* parent référent : " & Cells(6, 3) & Chr(10) & "-* téléphone référent : " & Cells(7, 3)
.Location = Cells(i, 10)
.Start = depart
.End = finrdv
.Categories = Cells(3, 6)
.ReminderSet = False 'pas de rappel
.Save
End With
Set OkApp = Nothing
End If
End If
Next i
End Sub |
Partager