The attached code works without problem, but only fires when I log onto my system each day. Even if I close my Outlook and re-open, the code will not fire. I can log-off my PC and then when I log back on and open my Outlook, the code fires....but that's the only way that it works. I need the action to fire when the appointment reminder opens. Is this happening because we are using "Private Sub Application_Startup"? Is there another option? I tried changing this line to "Private Sub Application_Reminder(ByVal
Item As Object)", but that didn't work either.
As always I look forward to some expert advice on this matter.
Public WithEvents objReminders As Outlook.Reminders, _
WithEvents objCalendarItems As Outlook.Items
Private Sub Application_Startup()
Dim objNS As NameSpace
Set objNS = Application.GetNamespace("MAPI")
Set objInboxItems = objNS.GetDefaultFolder(olFolderCalendar).Items
Set objNS = Nothing
Set objReminders = Application.Reminders
Private Sub objReminders_ReminderFire(ByVal ReminderObject As Reminder)
Dim objShell As Object, _
objAppointment As Object
Set objShell = CreateObject("Wscript.Shell")
If ReminderObject.Item.Class = olAppointment Then
Set objAppointment = ReminderObject.Item
'Change the start interval on the next line as desired. The interval is in minutes.
If DateDiff("n", Now, objAppointment.Start) <= 2 Then
If objAppointment.Categories = "LaunchAccess" Then
RetVal = Shell("C:\Appointment_Reminder\RunTextMessage.bat")
Set objAppointment = Nothing
Set objShell = Nothing