vincentt a écrit :
Bonjour,
J'ai bien l'année (2013) pour les dates anniversaires. Donc je ne vois pas le souci...
alors je pense qu'il doit y avoir un problème avec le format de date. Peut-être la date n'est-elle pas reconnue comme une date.
es-tu sûr que la date est en colonne H ?
tu peux envoyer un extrait de ton fichier (anonymisé), pour comprendre quel est ce problème de date ?
J'aurai une autre question : comment modifier le code pour créer un RDV à partir de la ligne sélectionnée ?
Merci pout ton aide,
Vincent
voici le code adapté, à tester
Sub Appointments()
Const olAppointmentItem As Long = 1
Dim OLApp As Object
Dim OLNS As Object
Dim OLAppointment As Object
On Error Resume Next
Set OLApp = GetObject(, "Outlook.Application")
If OLApp Is Nothing Then Set OLApp = CreateObject("Outlook.Application")
On Error GoTo 0
If Not OLApp Is Nothing Then
Set OLNS = OLApp.GetNamespace("MAPI")
OLNS.Logon
' créer des rendez-vous pour les lignes sélectionnées.
for each r in selection.rows
i=r.row
if range("h" & i) <>0 then
Set OLAppointment = OLApp.CreateItem(olAppointmentItem)
OLAppointment.Subject = "Anniversaire" & range("B" & i) & range("c" & i) & range("d" & i)
OLAppointment.Body = "Anniversaire" & range("B" & i) & range("c" & i) & range("d" & i)
OLAppointment.Start = range("h" & i)
OLAppointment.Duration = 60
OLAppointment.ReminderMinutesBeforeStart = 30
OLAppointment.Save
Set OLAppointment = Nothing
end if
next
Set OLNS = Nothing
Set OLApp = Nothing
End If
End Sub