FindNext Method Example

This Visual Basic for Applications example uses the GetDefaultFolder method to return the MAPIFolder object that represents the default Calendar folder for the current user. It then uses the Find and FindNext methods to locate all the appointments that occur today and display them in a series of message boxes.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
tdystart = Format(Date, "Short Date") & " 12:00 AM"
tdyend = Format(Date, "Short Date") & " 11:59 PM"
Set myAppointments = myNameSpace.GetDefaultFolder _
    (olFolderCalendar).Items
Set currentAppointment = myAppointments.Find("[Start] >= """ & _
    tdystart & """ and [Start] <= """ & tdyend & """")
While TypeName(currentAppointment) <> "Nothing"
    MsgBox currentAppointment.Subject
    Set currentAppointment = myAppointments.FindNext
Wend