Restrict Method
Applies To
Items collection object.
Description
Applies a filter to the Items collection, returning a new collection containing all items from the original which match the filter. This method is an alternative to using the Find method or FindNext method to iterate over specific items within a collection. Find or FindNext is faster than filtering if there are a small number of items. Restrict is useful where performance is not a concern.
Syntax
expression.Restrict(Filter)
expression An expression that returns an Items object.
Filter Required String. A filter string expression to be applied. For details, see the Find method.
Remarks
This property cannot be used, and will cause an error, with the following properties:
| |
| |
| |
- ReceivedOnBehalfOfEntryID
| |
| |
| |
See Also
Find method, FindNext method.
Example
This example gets all Inbox items dealing with Project X and moves them to the Project X folder.
Set myFolder = _
olNameSpace.GetDefaultFolder(olFolderInbox)
Set my Items = myFolder.Items
Set myRestrictItems = myItems.Restrict _
("[Categories] = 'Project X'")
For Each myItem In myRestrictItems
myItem.Move myFolder.Folders("Project X")
Next