Reading and processing Exchange Calendar Entries from...

J

Jim Kay

I am trying to automate a monthly activity calendar. A small number of people
will put their events into a single Exchange Calendar. There will also be
recurring events that are supposed to 'take care of themselves' unless
updated.

I want to produce a Word document that contains the events in a particular
month. It will be imported into Publisher.

Where can I go for some advice and maybe some sample code?

(I tried MSDN; Access and Excel are covered, Exchange isn't.)
 
P

Peter Huang [MSFT]

Hi

Do you mean the calendar in the ourlook?
I think it would be a complex scenario.
Here is some code snippet to enum the calendar item based on certain rule.
1. What kind of the calendar, if it is no recurring, then all is simple, we
just need to compare the item's Start(as a date) to know if it is in
certain month. Then dump the property,e.g. ci.Subject as below.
2. If it is recurring, it would be complex, we need to know its
RecurrenceType to further judge if the occurrence will be drop in certain
month by using PatternStartDate and PatternEndDate.
e.g. If it is olRecursWeekly , then the occurrent will occur every week
based.
3. We need to judge if its DayOfWeekMask, which means which days will be
true.

e.g. If the pattern is olRecursWeekly and DayOfWeekMask is olFriday, then
the pattern will be occur on every friday. So in common the recurrence will
be in the month, if the span between PatternStartDate and PatternEndDate
is in the month.

but we do have other RecurrenceTypes which need you design your algorithm
to evaluate whether or not the occurrence will in certian month.
RecurrenceType Properties Example
olRecursDaily Interval Every N days
DayOfWeekMask Every Tuesday, Wednesday, and Thursday
olRecursMonthly Interval Every N months
DayOfMonth The Nth day of the month
olRecursMonthNth Interval Every N months
Instance The Nth Tuesday
DayOfWeekMask Every Tuesday and Wednesday
olRecursWeekly Interval Every N weeks
DayOfWeekMask Every Tuesday, Wednesday, and Thursday
olRecursYearly DayOfMonth The Nth day of the month
MonthOfYear February
olRecursYearNth Instance The Nth Tuesday
DayOfWeekMask Tuesday, Wednesday, Thursday
MonthOfYear February

For detailed information you may try to consult the VBA help.
<Program Files>\Microsoft Office\OFFICE11\1033\VBAOL11.CHM

Here is a link about RecurrencePattern Object online.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaol11/htm
l/olobjRecurrencePattern_HV05247371.asp


Sub Test()
Dim mf As MAPIFolder
Set mf = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar)
Dim ci As AppointmentItem
For Each ci In mf.Items
If ci.IsRecurring = False Then
If ci.Start > #8/1/2005# And ci.Start < #9/1/2005# Then
Debug.Print ci.Subject
End If
Else
Dim pt As RecurrencePattern
Set pt = ci.GetRecurrencePattern
Debug.Print ci.Subject
Debug.Print pt.PatternStartDate
Debug.Print pt.PatternEndDate
End If
Next
End Sub

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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