Sorting Appointments Chronologically

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
 
K

Ken Slovak - [MVP - Outlook]

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.
 
G

Guest

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
 

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