This topic has not yet been rated - Rate this topic

Items.FindNext Method (Outlook)

Published: July 16, 2012

After the Find method runs, this method finds and returns the next Outlook item in the specified collection.

expression .FindNext

expression A variable that represents an Items object.

Return Value

An Object value that represents the next Outlook item found in the collection.

The search operation begins from the current position, which matches the expression previously set through the Find method.

The method returns an Outlook item object if the call succeeds; it returns Null (or Nothing in Visual Basic) if it fails.

This Visual Basic for Applications (VBA) example uses the GetDefaultFolder method to return the Folder 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.

Sub DemoFindNext() 
 Dim myNameSpace As Outlook.NameSpace 
 Dim tdystart As Date 
 Dim tdyend As Date 
 Dim myAppointments As Outlook.Items 
 Dim currentAppointment As Outlook.AppointmentItem 
 
 Set myNameSpace = Application.GetNamespace("MAPI") 
 tdystart = VBA.Format(Now, "Short Date") 
 tdyend = VBA.Format(Now + 1, "Short Date") 
 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 
End Sub

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.