[FONT=Fixedsys]Option Explicit[/FONT]
[FONT=Fixedsys]Option Compare Text[/FONT]
[FONT=Fixedsys]Public Sub Driver()[/FONT]
[FONT=Fixedsys] Call DeleteAppointments("wibble")[/FONT]
[FONT=Fixedsys]End Sub[/FONT]
[FONT=Fixedsys]Public Sub DeleteAppointments(ByVal argSubject As String)[/FONT]
[FONT=Fixedsys] Dim oApp As Outlook.Application[/FONT]
[FONT=Fixedsys] Dim oNameSpace As Outlook.Namespace[/FONT]
[FONT=Fixedsys] Dim oApptItem As Outlook.AppointmentItem[/FONT]
[FONT=Fixedsys] Dim oFolder As Outlook.MAPIFolder[/FONT]
[FONT=Fixedsys] Dim oMeetingoApptItem As Outlook.MeetingItem[/FONT]
[FONT=Fixedsys] Dim oObject As Object[/FONT]
[FONT=Fixedsys] Dim iUserReply As VbMsgBoxResult[/FONT]
[FONT=Fixedsys] Dim sErrorMessage As String[/FONT]
[FONT=Fixedsys] On Error Resume Next[/FONT]
[FONT=Fixedsys] ' check if Outlook is running[/FONT]
[FONT=Fixedsys] Set oApp = GetObject("Outlook.Application")[/FONT]
[FONT=Fixedsys] If Err <> 0 Then[/FONT]
[FONT=Fixedsys] 'if not running, start it[/FONT]
[FONT=Fixedsys] Set oApp = CreateObject("Outlook.Application")[/FONT]
[FONT=Fixedsys] End If[/FONT]
[FONT=Fixedsys] On Error GoTo Err_Handler[/FONT]
[FONT=Fixedsys] Set oNameSpace = oApp.GetNamespace("MAPI")[/FONT]
[FONT=Fixedsys] Set oFolder = oNameSpace.GetDefaultFolder(olFolderCalendar)[/FONT]
[FONT=Fixedsys] For Each oObject In oFolder.Items[/FONT]
[FONT=Fixedsys] If oObject.Class = olAppointment Then[/FONT]
[FONT=Fixedsys] Set oApptItem = oObject[/FONT]
[FONT=Fixedsys] If InStr(oApptItem.Subject, argSubject) > 0 Then[/FONT]
[FONT=Fixedsys][COLOR=blue] iUserReply = MsgBox("Appointment found:-" & vbCrLf & vbCrLf _[/COLOR][/FONT]
[FONT=Fixedsys][COLOR=blue] & Space(4) & "Date/time: " & Format(oApptItem.Start, "dd/mm/yyyy hh:nn") _[/COLOR][/FONT]
[FONT=Fixedsys][COLOR=blue] & " (" & oApptItem.Duration & "mins)" & Space(10) & vbCrLf _[/COLOR][/FONT]
[FONT=Fixedsys][COLOR=blue] & Space(4) & "Subject: " & oApptItem.Subject & Space(10) & vbCrLf _[/COLOR][/FONT]
[FONT=Fixedsys][COLOR=blue] & Space(4) & "Location: " & oApptItem.Location & Space(10) & vbCrLf & vbCrLf _[/COLOR][/FONT]
[FONT=Fixedsys][COLOR=blue] & "Delete this appointment?", vbYesNo + vbQuestion + vbDefaultButton2, "Delete Appointment?")[/COLOR][/FONT]
[FONT=Fixedsys][COLOR=blue] If iUserReply = vbYes Then[/COLOR] oApptItem.Delete[/FONT]
[FONT=Fixedsys] End If[/FONT]
[FONT=Fixedsys] End If[/FONT]
[FONT=Fixedsys] Next oObject[/FONT]
[FONT=Fixedsys] Set oApp = Nothing[/FONT]
[FONT=Fixedsys] Set oNameSpace = Nothing[/FONT]
[FONT=Fixedsys] Set oApptItem = Nothing[/FONT]
[FONT=Fixedsys] Set oFolder = Nothing[/FONT]
[FONT=Fixedsys] Set oObject = Nothing[/FONT]
[FONT=Fixedsys] Exit Sub[/FONT]
[FONT=Fixedsys]Err_Handler:[/FONT]
[FONT=Fixedsys] sErrorMessage = Err.Number & " " & Err.Description[/FONT]
[FONT=Fixedsys]End Sub[/FONT]