Scope Property
Returns a String that specifies the scope of the specified search. Read-only.
expression.Scope
expression Required. An expression that returns a Search object.
Remarks
The scope of the search is defined when the search is initiated. For more information, see the AdvancedSearch method.
Example
The following subroutine creates a Search object. The user's Inbox is specified as the scope of the search. The event subroutine occurs when the search has completed and displays the Tag and Scope properties for the new object as well as the results of the search.
Sub SearchInboxFolder()
'Searches the Inbox
Dim objSch As Search
Const strF As String = _
"urn:schemas:mailheader:subject = 'Office Christmas Party'"
Const strS As String = "Inbox"
Const strTag As String = "SubjectSearch"
Set objSch = Application.AdvancedSearch(Scope:=strS, _
Filter:=strF, SearchSubFolders:=True, Tag:=strTag)
End Sub
The AdvancedSearchComplete event is used to capture the results of the search.
Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search)
Dim objRsts As Results
MsgBox "The search " & SearchObject.Tag & _
"has completed. The scope of the search was " & _
SearchObject.Scope & "."
Set objRsts = SearchObject.Results
'Print out number in results collection
Debug.Print objRsts.Count
'Print out each member of results collection
For Each Item In objRsts
Debug.Print Item
Next
End Sub