Fraid not ADezii,
I am not getting any errors, have also tried taking out all reference to the .Start date and used just Subject & Location but it still comes back with Deleted 0 Appointments. This is crazy isnt it? Here is the code I am using which has been cahnged to the code you kindly gave me (I have made reference to .Start as a comment to see if this was the problem. Result of running the code is 0 Appointments deleted.
I have a calendar Appointment created for Room 9, Cyd and 4/10/2011 for 9;00 - 10:3O and a table appointment for the same room and name for 9AM to 10:30AM. I am trying to amend the booking so the above details are the details captured for the old booking and this appointment is to be deleted from outlook. It doesnt delet it however. With no error it is diffilcult to know what is wrong.
I am not getting any errors, have also tried taking out all reference to the .Start date and used just Subject & Location but it still comes back with Deleted 0 Appointments. This is crazy isnt it? Here is the code I am using which has been cahnged to the code you kindly gave me (I have made reference to .Start as a comment to see if this was the problem. Result of running the code is 0 Appointments deleted.
I have a calendar Appointment created for Room 9, Cyd and 4/10/2011 for 9;00 - 10:3O and a table appointment for the same room and name for 9AM to 10:30AM. I am trying to amend the booking so the above details are the details captured for the old booking and this appointment is to be deleted from outlook. It doesnt delet it however. With no error it is diffilcult to know what is wrong.
Code:
Delete_Old_Appointment:
' The Following variable assignments will pick-up the old booking data prior to the change in order
' to find and delete an Outlook booking. Variables have been caputured by the Sub Form_Current()procedure
' and declared Public in the basMyEmpID Standard Code Module.
Dim goldLocation As String
Dim goldStart As Date
Dim goldDate As Date
Dim goldName As String
goldLocation = basMyEmpID.gstroldLocation
goldStart = basMyEmpID.gdteoldStart
goldDate = basMyEmpID.gdteoldDate
goldName = basMyEmpID.gstroldName
' Connection to Outlook Variables
Dim objOlook As Outlook.Application
Dim objNamespace As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objAppointment As Outlook.AppointmentItem
Dim objOAppt As Outlook.Items
Dim lngDeletedAppointements As Long
Dim strSubject As String
Dim strLocation As String
Dim dteStartDate As Date
'******************************** Set Criteria for DELETION here ********************************
strSubject = goldName
strLocation = goldLocation
dteStartDate = goldDate & " " & goldStart ' goldDate is Short Date goldStart is medium time
MsgBox (strSubject & dteStartDate & strLocation)
'************************************************************************************************
Set objOlook = CreateObject("Outlook.Application")
Set objNamespace = objOlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderCalendar)
For Each objAppointment In objFolder.Items
If objAppointment.Subject = strSubject And objAppointment.Location = strLocation Then _
'objAppointment.Start = CDate(Format$(dteStartDate, "Short Date"))
objAppointment.Delete
lngDeletedAppointements = lngDeletedAppointements + 1
End If
Next
MsgBox lngDeletedAppointements & " appointment(s) DELETED.", vbInformation, "DETETE Appointments"
'I 'm sure that you will now be able to adapt it to your specific
GoTo Ender
Exit Sub
Comment