A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Removing recurrence in VBA



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 19th 08, 07:42 PM posted to microsoft.public.outlook.program_vba
JoeMarfice
external usenet poster
 
Posts: 1
Default Removing recurrence in VBA

I have a large number (600+) of appointments that have become mislabeled as
weekly recurring appointments. Their start times are all correct, and their
end times are mostly one day later (all day appointments); all of them are in
the past.

Unfortunately, now all of these appointments appear as current events
(NoEndDate).

I tried using the following code to remove the recurrences, and preserve the
start date and times, but it seems to do nothing (although the code inside
the inner if-then loop is activated 600+ times).

What am I missing?

************************************************** ********

Sub FixWeeklyAllDayAppointments()

Dim lngNumShiftedAppointments As Long
Dim datPatternStartDate As Date
Dim mapiAppointments As MAPIFolder
Dim itmAppointment As AppointmentItem

lngNumShiftedAppointments = 0

Set mapiAppointments = Outlook.Application. _
GetNamespace("MAPI").GetDefaultFolder(olFolderCale ndar)

For Each itmAppointment In mapiAppointments.Items
With itmAppointment
If (.AllDayEvent = False) Then

If (Format(.GetRecurrencePattern.StartTime, "HH:MM") = "00:00") _
And (.GetRecurrencePattern.RecurrenceType = olRecursWeekly)
Then
' These particular events have been buggered.
.ClearRecurrencePattern
.RecurrenceState
.Save
lngNumShiftedAppointments = lngNumShiftedAppointments + 1
End If
End If
End With
Next

Set mapiAppointments = Nothing
Set itmAppointment = Nothing

MsgBox lngNumShiftedAppointments " bad Appointments were found & corrected."

Exit Sub
Ads
  #2  
Old November 20th 08, 03:06 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Removing recurrence in VBA

You do know that using GetRecurrencePattern() will make an item recurring
even if it isn't recurring, don't you? You should check first for
itmAppointment.IsRecurring() and only get the recurrence pattern if the item
is already recurring.

I don't know if that's the problem but I'd make that change anyway. I'd also
eliminate the access to RecurrenceState since you aren't doing anything with
it and not even actually reading its value.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"JoeMarfice" wrote in message
news
I have a large number (600+) of appointments that have become mislabeled as
weekly recurring appointments. Their start times are all correct, and
their
end times are mostly one day later (all day appointments); all of them are
in
the past.

Unfortunately, now all of these appointments appear as current events
(NoEndDate).

I tried using the following code to remove the recurrences, and preserve
the
start date and times, but it seems to do nothing (although the code inside
the inner if-then loop is activated 600+ times).

What am I missing?

************************************************** ********

Sub FixWeeklyAllDayAppointments()

Dim lngNumShiftedAppointments As Long
Dim datPatternStartDate As Date
Dim mapiAppointments As MAPIFolder
Dim itmAppointment As AppointmentItem

lngNumShiftedAppointments = 0

Set mapiAppointments = Outlook.Application. _
GetNamespace("MAPI").GetDefaultFolder(olFolderCale ndar)

For Each itmAppointment In mapiAppointments.Items
With itmAppointment
If (.AllDayEvent = False) Then

If (Format(.GetRecurrencePattern.StartTime, "HH:MM") = "00:00")
_
And (.GetRecurrencePattern.RecurrenceType = olRecursWeekly)
Then
' These particular events have been buggered.
.ClearRecurrencePattern
.RecurrenceState
.Save
lngNumShiftedAppointments = lngNumShiftedAppointments + 1
End If
End If
End With
Next

Set mapiAppointments = Nothing
Set itmAppointment = Nothing

MsgBox lngNumShiftedAppointments " bad Appointments were found &
corrected."

Exit Sub


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
recurrence da-obrienarch Outlook - Calandaring 1 September 28th 07 04:55 PM
Trying to set a recurrence Gail Outlook - Calandaring 1 September 19th 07 08:14 AM
Remove Recurrence is gray out - how do I stop Recurrence? Marty Outlook - Calandaring 1 April 27th 07 01:24 PM
Recurrence Question: "Second Tuesday" type recurrence pattern in Outlook [email protected] Outlook - General Queries 3 January 12th 07 12:54 PM
Removing a recurrence bill Outlook - General Queries 4 November 8th 06 12:42 PM


All times are GMT +1. The time now is 11:10 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.