Mitch Schwartz
asked on
Outlook Automation in Access Using "Find"
I am trying to use VBA Automation in Access 2013 to find and open appointments using filter criteria. The code "finds" the appointment, but when I try to open the found appointment (in Outlook) I get Error 91 ("Object variable not set"). The error occurs when I use the .Display method of the Appointment object. Here's the code:
Sub FindOutlookAppt()
Dim olApp As Outlook.Application
Dim objAppointment As Outlook.AppointmentItem
Dim objAppointments As Outlook.MAPIFolder
Dim objNameSpace As Outlook.NameSpace
Dim objProperty As Outlook.UserProperty
Dim OutlookStartTime, OutlookEndTime As Date
Dim sFilter As Variant
Set olApp = CreateObject("Outlook.Application")
Set objNameSpace = olApp.GetNamespace("MAPI")
Set objAppointments = objNameSpace.GetDefaultFolder(olFolderCalendar)
sFilter = "[Subject] = '" & "Workout" & "'"
Set objAppointment = objAppointments.Items.Find(sFilter)
objAppointment.Display
Set objAppointment = Nothing
Set objAppointments = Nothing
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER