I have managed to get a sample form to work that creates a new contact
and sets up a new appointment (taken from the MS web site).
I have also managed to find some VBSCRIPT in a newsgroup which will
delete ALL appointments in a calendar (although I have nit run it as
am rather fond of some of my existing appointments).
I know I am asking a lot here, but - could someone provide me with
some code that that would delete all occurrences of an appointment
that has (for example) the word 'Holiday' in the subject line?
A million thanks in advance.......
Sub DeleteSpecifiedAppointments()
Dim objNS As Outlook.NameSpace
Dim objApptFolder As Outlook.MAPIFolder, objAppt As
Outlook.AppointmentItem
Dim objItems As Outlook.Items, intX As Integer
Set objNS = Application.GetNamespace("MAPI")
Set objApptFolder = objNS.GetDefaultFolder(olFolderCalendar)
Set objItems = objApptFolder.Items
For intX = 1 To objItems.Count
Set objAppt = objItems.Item(intX)
If objAppt.Categories = "Holiday" Then
objAppt.Delete
End If
Next
End Sub
--
Eric Legault, MCSD
ADAPSYS - http://www.adapsys.ca
"Jordan" <jordanmc...@totalise.co.uk> wrote in message
news:e8096ce.03011...@posting.google.com...
"Eric Legault" <ericatwor...@shaw.ca> wrote in message news:<uvwT1wMuCHA.2620@TK2MSFTNGP11>...
> If objAppt.Categories = "Holiday" Then
to
> If objAppt.Subject = "This is a test appointment" Then
and it works brilliantly (it also works when I create a recurring
appointment and try to delete it). (It did say 'array out of range'
at one point - but it still worked...)
(And I think in actual fact - VBA WAS what I was looking for rather
than VBScript).
So you have answered my question 100%.
The only problem is (and this is where it gets a bit more complicated
- and I would not blame you if you lost all interest at this point) :-
Our PCs have a 3rd party form enabled against the calendar - which
gives an extra tab when creating an appointment for the entry of case
details. This form does not work correctly. i.e. when someone is
invited to the appointment - it normally does not allow that person to
accept the appointment (it gives an 'unknow error' when they click on
'accept'). But somehow - this time - the appointment was accepted
into the calendar (and it recurs every day for the next 100 years or
so) - and when you try to manually delete the whole series in one go,
you get an 'unknow error'. But when you delete a single occurrence -
it does work!. It would take me probably hundreds of hours to delete
each individual occurrence manually - hence the desire for the macro.
Unfortunately - the macro also gives an unknown error when trying to
delete the rogue appointment.............
Not sure what to do now.....:-(
"Eric Legault" <ericatwor...@shaw.ca> wrote in message news:<uvwT1wMuCHA.2620@TK2MSFTNGP11>...