Search.Save method (Outlook)

Saves the search results to a Search Folder.


expression.Save (SchFldrName)

expression A variable that represents a Search object.


Name Required/Optional Data type Description
SchFldrName Required String A string that represents the Search Folder name.


The Save method displays an error if a Search Folder with the same name already exists.


The following Microsoft Visual Basic for Applications (VBA) example searches the Inbox for items with Subject line equal to 'Test' and saves the results in a Search Folder. 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, and the TestAdvancedSearchComplete() procedure must be called before the event procedure can be called by 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 
 sch.Save("Subject Test") 
End Sub

See also

Search Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.