26.7. Searching for Items

To search for items, use the AdvancedSearch method of the Application object. The syntax is as follows:

expression .AdvancedSearch(Scope, Filter, SearchSubFolders, Tag)

Here are the components of the syntax:

  • expression is a required expression that returns an Application object.

  • Scope is a required String argument that specifies the scope of the search (which items to search). Usually you'll search a particular folder. For example, you might search the Inbox for messages that match certain criteria, or you might search the Tasks folder for particular tasks.

  • Filter is an optional Variant argument that specifies the search filter. While this argument is optional, you will need to use it unless you want to return all the ...

Get Mastering VBA for Microsoft Office 2007, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.