deleting appointmets in 1 specific month

F

Filips Benoit

Dear All,

The code below does not run always correctly.
Somethimes appointments in the specific month has not been deleted !

Can't see why!

'Delete all appointment in this month
For Each objAppointement In myNewFolder.Items
If Month(objAppointement.Start) = iMonth And
Year(objAppointement.Start) = iYear Then objAppointement.Delete
DoEvents
Next

Thanks,

Filip
 
F

Filips Benoit

Without any reason the action leaves the loop and stops deleting items befor
the end of the appointmentcollection.
If I run the loop twice it deletes more appointments but not all in the
specific month.
Another run may be perfect!

VERRY STRANGE !!

Filip

"Filips Benoit" wrote in message
Dear All,

The code below does not run always correctly.
Somethimes appointments in the specific month has not been deleted !

Can't see why!

'Delete all appointment in this month
For Each objAppointement In myNewFolder.Items
If Month(objAppointement.Start) = iMonth And
Year(objAppointement.Start) = iYear Then objAppointement.Delete
DoEvents
Next

Thanks,

Filip
 
D

Diane Poremsky

You need to step backwards - when you move forward you'll skip every
other appt. to do this you need to get a count of appt first then run
through them backwards:


For i = [#of appt] To 1 Step -1

[delete appts]

Next i

Diane Poremsky [MVP - Outlook]

Outlook & Exchange Solutions Center: http://www.slipstick.com/
OutlookForums http://www.outlookforums.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top