G'DAY Composer,
The code below is presented 'as is' - I have not used it in
4 or 5 years.
It was behind an XL Sheet that I used to List Expenses.
The data came from Outlook, where a custom
appointment form used a couple of custom properties.
The Code sets up some dates, between which are the target
appointments - you may ignore this.
The essential feature for you, is the line:
ThisSet.IncludeRecurrences = True
which includes all recurrences (of any appointments).
The dates are in dd/mmm/yy format.
--
Regards,
Pat Garard
Melbourne, Australia
_______________________
=======================================
Sub ListAppointments()
Sheets("Expenses").Activate
' Declare all the variables
Dim olApplication As Outlook.Application
Dim olNameSpace As NameSpace
Dim objCalendar As Object
Dim objApptmt As Object
Dim myProp As Object
Dim ThisSet As Object
Dim Today As Date
Dim EndDay As Date
Dim DaysToSaturday As Integer
Dim getError As Integer
Dim Criteria As String
' Start Outlook and target the Calendar
getError = 0
On Error GoTo NotRunning
Set olApplication = GetObject(, "Outlook.Application")
NotRunning:
If Err.Number = 429 Then
Set olApplication = CreateObject("Outlook.Application")
getError = Err.Number
End If
On Error GoTo 0
Set olNameSpace = olApplication.GetNamespace("MAPI")
Set objCalendar = olNameSpace.GetDefaultFolder(olFolderCalendar)
' What is the date? Calculate to NEXT Saturday
Today = Now()
DaysToSaturday = 7 - WeekDay(Today)
EndDay = Format(DateAdd("d", DaysToSaturday, Now()), "dd/mm/yy")
' Focus on Appointment Items and Recurrences
Set ThisSet = objCalendar.Items
' ... and Restrict it.
Criteria = "[Start] < ""#" & EndDay & "#"" And [Sensitivity] <> 2" '
Const olPrivate = 2
Set ThisSet = ThisSet.Restrict(Criteria)
' Sort and include recurrences
ThisSet.Sort "[Start]"
ThisSet.IncludeRecurrences = True
' Lets see whats happening, ...
Application.ScreenUpdating = True
' ... focus on the right spot, ...
Sheets("Expenses").Activate
' ... and clear the decks!
Range("C1").Value = EndDay
ActiveSheet.Range("A5").CurrentRegion.ClearContents
' Lets do it
Range("A5").Select
For Each objApptmt In ThisSet
With objApptmt
' Only non-Holiday, uninvoiced appointments
If InStr(1, .Categories, "Holiday") = 0 Then
' Fix any stray recurrences without User Props
If .UserProperties.Count = 0 Then
' We need to know so we can fix Outlook vbScript
MsgBox .Subject & Str(.Start), vbOKOnly, "No User
Properties"
Set myProp = .UserProperties.Add("Parking", olCurrency)
myProp.Value = 0
Set myProp = .UserProperties.Add("Meals", olCurrency)
myProp.Value = 0
Set myProp = .UserProperties.Add("Invoiced", olYesNo)
myProp.Value = olNoFlag
.Save
End If
' Now list the expenses
If .UserProperties("Invoiced") = False Then
ActiveCell.Value = CDate(.Start)
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = CStr(.Subject)
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = CStr(.Location)
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = CStr(.Mileage)
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = CCur(.UserProperties("Parking"))
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = CCur(.UserProperties("Meals"))
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = CBool(.UserProperties("Invoiced"))
ActiveCell.Offset(1, -6).Activate
End If
End If
End With
Next
Set olApplication = Nothing
Range("A5").Select
End Sub
=======================================