共用方式為


AdvancedSearchStopped Event

Occurs when a specified **Search**object's Stop method has been executed.

Private Subapplication**_ AdvancedSearchStopped**(ByVal SearchObject As Object)

*expression   * A variable that references an object of type Application declared with events in a class module.

*SearchObject   * The Search object returned by the **AdvancedSearch**method.

Remarks

After this event is fired, the Search object's **Results**collection will no longer be updated. This event can only be triggered programmatically.

Example

The following Visual Basic for Applications (VBA) example starts searching the Inbox for items with subject equal to "Test" and immediately stops the search. This causes the AdvanceSearchStopped event procedure to be run. The sample code must be placed in a class module such as ThisOutlookSession. The StopSearch() procedure must be called before the event procedure can be called by Microsoft Outlook.

Sub StopSearch()
    Dim sch As Outlook.Search
    Dim strScope As String
    Dim strFilter As String
    strScope = "Inbox"
    strFilter = "urn:schemas:httpmail:subject = 'Test'"
    Set sch = Application.AdvancedSearch(strScope, strFilter)
    sch.Stop
End Sub
 
Private Sub Application_AdvancedSearchStopped(ByVal SearchObject As Search)
    'Inform the user that the search has stopped.
    MsgBox "An AdvancedSearch has been interrupted and stopped. "
End Sub

Applies to | Application Object

See Also | AdvancedSearch Method | AdvancedSearchComplete Event