Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

AdvancedSearchComplete Event

Office 2003

Occurs when the AdvancedSearch method has completed. The AdvancedSearchComplete event is used to return the object that was created by the AdvancedSearch method.

Private Sub expression_ AdvancedSearchComplete(ByVal SearchObject As Object)

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

SearchObject    The Search object returned by the AdvancedSearch method.

Remarks

This event only fires when the AdvancedSearch method is executed programmatically.

Example

The following Visual Basic for Applications (VBA) example searches the Inbox for items where the subject is equal to "Test" and displays the names of the senders of the e-mail items returned by the search. The AdvanceSearchComplete event procedure sets the boolean blnSearchComp to True when the search is complete. This boolean variable is used by the TestAdvancedSearchComplete() procedure to determine when the search is complete. The sample code must be placed in a class module such as ThisOutlookSession. The TestAdvancedSearchComplete() procedure must be called before the event procedure can be called by Microsoft Outlook.

Public blnSearchComp As Boolean

Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search)
	MsgBox "The AdvancedSearchComplete Event fired."
	blnSearchComp = True
End Sub

Sub TestAdvancedSearchComplete()
	Dim sch As Outlook.Search
	Dim rsts As Outlook.Results
	Dim i As Integer
 	blnSearchComp = False
	Const strF As String = "urn:schemas:mailheader:subject = 'Test'"
	Const strS As String = "Inbox"   
	Set sch = Application.AdvancedSearch(strS, strF) 
	While blnSearchComp = False
		DoEvents
	Wend 
	Set rsts = sch.Results
	For i = 1 To rsts.Count
		MsgBox rsts.Item(i).SenderName
	Next
End Sub

		


Applies to | Application Object



Show:
© 2015 Microsoft