I am trying to delete an outlook appointment based upon the value of variables for Location, Start Date, Start Time & Name (Subject)
I am at a loss as where to start on declarations for Outlook Objects. I found some code on the Web and tried to alter it. Could you please help with the declarations for finding the appointment in Outlook. My rubbish attempt at coding is as follows:-
If I can have some help on declaration I could possibly work out the rest.
Many thanks in advance
I am at a loss as where to start on declarations for Outlook Objects. I found some code on the Web and tried to alter it. Could you please help with the declarations for finding the appointment in Outlook. My rubbish attempt at coding is as follows:-
Code:
Dim olApp As Outlook.Application
Dim objAppts As Outlook.AppointmentItem
Dim AP_Date As Date
Dim AP_Start_Time As Date
Dim AP_Location As String
Dim AP_Subject As String
Dim OutlookStartTime As Date
Dim OutlookLocation As String
Dim OutlookSubject As String
Dim sFilter As Variant
AP_Date = Module1.oldDate
AP_Start_Time = Module1.oldStart
AP_Location = Module1.oldLocation
AP_Subject = Module1.oldName
OutlookStartTime = CDate(AP_Date & " " & AP_Start_Time)
OutlookLocation = (AP_Location)
OutlookSubject = (AP_Subject)
Set olApp = CreateObject("Outlook.Application")
Set objAppointments = objAppts.DeleteItem(olAppointmentItem)
sFilter = "[Start] = '" & OutlookStartTime & _
"' And [Location] = '" & OutlookLocation & "' " & _
" And [Subject] = '" & OutlookSubject & "'"
Set objAppointments = objAppointments.Items.Find(sFilter)
If Not TypeName(objAppointments) = "Nothing" Then
MsgBox ("Appointment Found")
'objAppointment.Delete
End If
Set objAppointments = Nothing
Set objAppts = Nothing
Exit Sub
Many thanks in advance
Comment