PC Review


Reply
Thread Tools Rate Thread

How to change an item from a recurring Appointment item to an exception from VB code?

 
 
Dikbill
Guest
Posts: n/a
 
      12th Jul 2006
Hi there,

I have an VB 2005 application from which I can adjust Outlook 2003 items.
My question is how can I change one of the Appointment items from the
recurring
set to an exception item without altering the other items?

Many thnx,

Dikbill, The Netherlands
(E-Mail Removed)


 
Reply With Quote
 
 
 
 
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==
Guest
Posts: n/a
 
      12th Jul 2006
You have to first find the recurring item, then get the RecurrencePattern
object for it, then get an individual AppointmentItem occurrence by the
GetOccurenceMethod, then change the Start and/or End dates to make it an
Exception. Then use the Exceptions collection from the RecurrencePattern to
get that particular Exception object.

Here's an example from the VBA help file:

Public Sub cmdExample()
Dim myOlApp As Outlook.Application
Dim myApptItem As Outlook.AppointmentItem
Dim myRecurrPatt As Outlook.RecurrencePattern
Dim myNamespace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myItems As Outlook.Items
Dim myDate As Date
Dim myOddApptItem As Outlook.AppointmentItem
Dim saveSubject As String
Dim newDate As Date
Dim myException As Outlook.Exception
Set myOlApp = New Outlook.Application
Set myApptItem = myOlApp.CreateItem(olAppointmentItem)
myApptItem.Start = #2/2/2003 3:00:00 PM#
myApptItem.End = #2/2/2003 4:00:00 PM#
myApptItem.Subject = "Meet with Boss"

'Get the recurrence pattern for this appointment
'and set it so that this is a daily appointment
'that begins on 2/2/03 and ends on 2/2/04
'and save it.
Set myRecurrPatt = myApptItem.GetRecurrencePattern
myRecurrPatt.RecurrenceType = olRecursDaily
myRecurrPatt.PatternStartDate = #2/2/2003#
myRecurrPatt.PatternEndDate = #2/2/2004#
myApptItem.Save

'Access the items in the Calendar folder to locate
'the master AppointmentItem for the new series.
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderCalendar)
Set myItems = myFolder.Items
Set myApptItem = myItems("Meet with Boss")

'Get the recurrence pattern for this appointment
'and obtain the occurrence for 3/12/03.
myDate = #3/12/2003 3:00:00 PM#
Set myRecurrPatt = myApptItem.GetRecurrencePattern
Set myOddApptItem = myRecurrPatt.GetOccurrence(myDate)

'Save the existing subject. Change the subject and
'starting time for this particular appointment
'and save it.
saveSubject = myOddApptItem.Subject
myOddApptItem.Subject = "Meet NEW Boss"
newDate = #3/12/2003 3:30:00 PM#
myOddApptItem.Start = newDate
myOddApptItem.Save

'Get the recurrence pattern for the master
'AppointmentItem. Access the collection of
'exceptions to the regular appointments.
Set myRecurrPatt = myApptItem.GetRecurrencePattern
Set myException = myRecurrPatt.Exceptions.item(1)

'Display the original date, time, and subject
'for this exception.
MsgBox myException.OriginalDate & ": " & saveSubject

'Display the current date, time, and subject
'for this exception.
MsgBox myException.AppointmentItem.Start & ": " & _
myException.AppointmentItem.Subject
End Sub

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Dikbill" wrote:

> Hi there,
>
> I have an VB 2005 application from which I can adjust Outlook 2003 items.
> My question is how can I change one of the Appointment items from the
> recurring
> set to an exception item without altering the other items?
>
> Many thnx,
>
> Dikbill, The Netherlands
> (E-Mail Removed)
>
>
>

 
Reply With Quote
 
Dikbill
Guest
Posts: n/a
 
      13th Jul 2006
Eric,

Thanx for your quick response!
It works like a charm :-)
I would have nerver figured that out myself.....

Regards,

Dikbill, The Netherlands
(E-Mail Removed)


"Eric Legault [MVP - Outlook]" <(E-Mail Removed)> schreef in
bericht news:5E6EA564-4E7B-4FD5-885B-(E-Mail Removed)...
> You have to first find the recurring item, then get the RecurrencePattern
> object for it, then get an individual AppointmentItem occurrence by the
> GetOccurenceMethod, then change the Start and/or End dates to make it an
> Exception. Then use the Exceptions collection from the RecurrencePattern
> to
> get that particular Exception object.
>
> Here's an example from the VBA help file:
>
> Public Sub cmdExample()
> Dim myOlApp As Outlook.Application
> Dim myApptItem As Outlook.AppointmentItem
> Dim myRecurrPatt As Outlook.RecurrencePattern
> Dim myNamespace As Outlook.NameSpace
> Dim myFolder As Outlook.MAPIFolder
> Dim myItems As Outlook.Items
> Dim myDate As Date
> Dim myOddApptItem As Outlook.AppointmentItem
> Dim saveSubject As String
> Dim newDate As Date
> Dim myException As Outlook.Exception
> Set myOlApp = New Outlook.Application
> Set myApptItem = myOlApp.CreateItem(olAppointmentItem)
> myApptItem.Start = #2/2/2003 3:00:00 PM#
> myApptItem.End = #2/2/2003 4:00:00 PM#
> myApptItem.Subject = "Meet with Boss"
>
> 'Get the recurrence pattern for this appointment
> 'and set it so that this is a daily appointment
> 'that begins on 2/2/03 and ends on 2/2/04
> 'and save it.
> Set myRecurrPatt = myApptItem.GetRecurrencePattern
> myRecurrPatt.RecurrenceType = olRecursDaily
> myRecurrPatt.PatternStartDate = #2/2/2003#
> myRecurrPatt.PatternEndDate = #2/2/2004#
> myApptItem.Save
>
> 'Access the items in the Calendar folder to locate
> 'the master AppointmentItem for the new series.
> Set myNamespace = myOlApp.GetNamespace("MAPI")
> Set myFolder = myNamespace.GetDefaultFolder(olFolderCalendar)
> Set myItems = myFolder.Items
> Set myApptItem = myItems("Meet with Boss")
>
> 'Get the recurrence pattern for this appointment
> 'and obtain the occurrence for 3/12/03.
> myDate = #3/12/2003 3:00:00 PM#
> Set myRecurrPatt = myApptItem.GetRecurrencePattern
> Set myOddApptItem = myRecurrPatt.GetOccurrence(myDate)
>
> 'Save the existing subject. Change the subject and
> 'starting time for this particular appointment
> 'and save it.
> saveSubject = myOddApptItem.Subject
> myOddApptItem.Subject = "Meet NEW Boss"
> newDate = #3/12/2003 3:30:00 PM#
> myOddApptItem.Start = newDate
> myOddApptItem.Save
>
> 'Get the recurrence pattern for the master
> 'AppointmentItem. Access the collection of
> 'exceptions to the regular appointments.
> Set myRecurrPatt = myApptItem.GetRecurrencePattern
> Set myException = myRecurrPatt.Exceptions.item(1)
>
> 'Display the original date, time, and subject
> 'for this exception.
> MsgBox myException.OriginalDate & ": " & saveSubject
>
> 'Display the current date, time, and subject
> 'for this exception.
> MsgBox myException.AppointmentItem.Start & ": " & _
> myException.AppointmentItem.Subject
> End Sub
>
> --
> Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
> Try Picture Attachments Wizard for Outlook:
> http://www.collaborativeinnovations.ca
> Blog: http://blogs.officezealot.com/legault/
>
>
> "Dikbill" wrote:
>
>> Hi there,
>>
>> I have an VB 2005 application from which I can adjust Outlook 2003 items.
>> My question is how can I change one of the Appointment items from the
>> recurring
>> set to an exception item without altering the other items?
>>
>> Many thnx,
>>
>> Dikbill, The Netherlands
>> (E-Mail Removed)
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
open appointment item - how to change time? news.chello.at Microsoft Outlook VBA Programming 5 11th Oct 2010 10:02 PM
Outlook 2007 recurring appointment error "Cannot open this item" Kat Barnes Microsoft Outlook Calendar 0 22nd Oct 2007 09:42 PM
Recurring item based on another recurring item =?Utf-8?B?QmlsbCBCcmFkbGV5?= Microsoft Outlook Calendar 0 14th Nov 2006 11:33 PM
Saving exception item in recurring appointment item fails Dikbill Microsoft Outlook VBA Programming 2 11th Jul 2006 03:59 PM
Saving exception item in recurring appointment item fails Dikbill Microsoft Outlook Calendar 0 11th Jul 2006 02:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:21 AM.