Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Create a Macro in Outlook 2000 to delete all appointments with specific wording in Calendar?

7 views
Skip to first unread message

Jordan

unread,
Jan 10, 2003, 11:11:40 AM1/10/03
to
I am a total beginner to VBSCRIPT.

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.......

Eric Legault

unread,
Jan 10, 2003, 12:14:15 PM1/10/03
to
This should get you started. It's VBA, so you have a little homework to
convert it to VBScript. Note that if you're trying to delete some of the
default Outlook holidays, you should check the Category property rather than
the subject line. If that's no good for you, than check the Subject
property instead.

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...

Jordan

unread,
Jan 13, 2003, 3:59:12 AM1/13/03
to
Thanks for the reply. I'll give this a go.

"Eric Legault" <ericatwor...@shaw.ca> wrote in message news:<uvwT1wMuCHA.2620@TK2MSFTNGP11>...

Jordan

unread,
Jan 13, 2003, 4:46:19 AM1/13/03
to
I created a load of separate appointments with 'This is a test
appointment' in the subject line and chnegd the following line:

> 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>...

0 new messages