PDA

View Full Version : Excel VBA to Outlook canlendar set reminder



Albuquerque
04-20-2021, 04:28 AM
I have this VBA code performing after a click of a button:

Dim ol As Outlook.Application
Dim olAp As Outlook.AppointmentItem

Set ol = New Outlook.Application
Set olAp = ol.CreateItem(olAppointmentItem)

With olAp
.Subject = Cells(7, 2) & " - " & Cells(7, 4) & " - " & Cells(7, 5)
.Location = Cells(7, 3)
.Start = Cells(7, 16)
.AllDayEvent = True
.ReminderSet = True
.ReminderMinutesBeforeStart = 4320
.body = Cells(7, 19)
.display
End With

The objective is that automatically the reminder is set to 3 days before the appoitment.

However Outlook Calendar keeps the reminder at 18h.

How can I solve this?

Kenneth Hobs
04-22-2021, 12:13 PM
Welcome to the forum!

All day events have an issue setting the reminder that long. You may have an issue with your start time.

A workaround like this might meet your needs. I used start date as 4 days from current date.

Sub SetReminder() Dim ol As Outlook.Application
Dim olAp As Outlook.AppointmentItem
Dim d As Double

Set ol = New Outlook.Application
Set olAp = ol.CreateItem(olAppointmentItem)

With olAp
.Subject = Cells(7, 2) & " - " & Cells(7, 4) & " - " & Cells(7, 5)
.Location = Cells(7, 3)
d = Now + 4 * 24
d = DateSerial(Year(d), Month(d), Day(d))
.Start = d 'Cells(7, 16)
.End = d + TimeSerial(23, 59, 0)
.AllDayEvent = False
'.AllDayEvent = True
.ReminderMinutesBeforeStart = 3 * 24 * 60
.ReminderSet = True
.body = Cells(7, 19)
.display
End With
End Sub