Sorting Appointments Chronologically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the following code to loop through all the appointment in Outlook

***
Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objCalendarFolder As Outlook.MAPIFolder
Dim objItems As Outlook.Items
Dim objAppt As Outlook.AppointmentItem

Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
Set objCalendarFolder = objNS.GetDefaultFolder(olFolderCalendar)
Set objItems = objCalendarFolder.Items.Restrict("[Start] >= '" &
Format(Date, "ddddd h:nn AMPM") & "'")

For Each objAppt In objItems
...
***

It does work, but is there a way to control the chrononlogical order of the
returned appointments? Is there a way to sort the ObjItems
Assending/Descending depending on my needs?

Thank you,

Daniel P
 
How about using the Items.Sort() method?

Look up the arguments for that method in the Object Browser Help, you can
sort on a property and make it ascending or descending.
 
I will take a look! Thank you for putting me on the right path.

Daniel P




Ken Slovak - said:
How about using the Items.Sort() method?

Look up the arguments for that method in the Object Browser Help, you can
sort on a property and make it ascending or descending.




Daniel said:
I am using the following code to loop through all the appointment in
Outlook

***
Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objCalendarFolder As Outlook.MAPIFolder
Dim objItems As Outlook.Items
Dim objAppt As Outlook.AppointmentItem

Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
Set objCalendarFolder = objNS.GetDefaultFolder(olFolderCalendar)
Set objItems = objCalendarFolder.Items.Restrict("[Start] >= '" &
Format(Date, "ddddd h:nn AMPM") & "'")

For Each objAppt In objItems
...
***

It does work, but is there a way to control the chrononlogical order of
the
returned appointments? Is there a way to sort the ObjItems
Assending/Descending depending on my needs?

Thank you,

Daniel P
 
Back
Top