Outlook Macros‎ > ‎

Set Birthday/Anniversary Reminders

Following macro changes (it does not set reminder if it is not set already) reminders for birthday/anniversary events to configured number of hours before event (because by default it is 15 minutes before midnight and one does not want to be woken by Android at that time). This macro is useful for situation when birthday event is not synchronized with reminder time (which can happen rarely on specific conditions).

License: GPL

Sub SetSpecEventReminders()
  Dim ns As NameSpace
  Dim f As Folder
  Dim t As AppointmentItem
  Dim rp As RecurrencePattern
  Dim istr As String
  Dim remtime As Integer
  Dim n As Integer
 
  Set ns = Application.GetNamespace("MAPI")
  Set f = ns.GetDefaultFolder(olFolderCalendar)
 
  istr = InputBox("Number of hours before event")
 
  If Not IsNumeric(istr) Then
    MsgBox "Input is incorrect, macro will not continue."
    Exit Sub
  End If
 
  remtime = CInt(istr) * 60
  n = 0
 
  For Each i In f.Items
    If i.Class = olAppointment Then
      Set t = i
     
      If t.IsRecurring And t.ReminderSet And t.AllDayEvent Then
         Set rp = t.GetRecurrencePattern()
        
         If rp.RecurrenceType = olRecursYearly And rp.Interval = 12 And rp.NoEndDate Then
           If (t.ReminderMinutesBeforeStart <> remtime) Then
             t.ReminderMinutesBeforeStart = remtime
             t.Save
             n = n + 1
           End If
         End If
      End If
    End If
  Next
 
  MsgBox "Changed " & n & IIf(n = 1, " event", " events")
End Sub
Comments