Outlook) (Search.Scope 屬性

會傳回 String,此字串指定所指定搜尋的範圍。 唯讀。

語法

expression。 Scope

運算式 代表 Search 物件的變數。

註解

當搜尋起始時,即已定義搜尋的範圍。 如需詳細資訊,請參閱 AdvancedSearch 方法。

範例

下列Microsoft Visual Basic for Applications (VBA) 範例會建立 Search 物件。 使用者的 [收件匣 ] 會指定為搜尋範圍。 搜尋完成時,會發生事件子常式,除了搜尋結果之外,還會顯示新物件的 「標籤」 及 「範圍」 內容。

Public blnSearchComp As Boolean 
 
 
 
Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search) 
 
 MsgBox "The AdvancedSearchComplete Event fired for " & SearchObject.Tag & " and the scope was " & SearchObject.Scope 
 
 blnSearchComp = True 
 
End Sub 
 
 
 
Sub TestAdvancedSearchComplete() 
 
 'List all items in the Inbox that do NOT have a flag. 
 
 Dim objSch As Outlook.Search 
 
 Const strF As String = "urn:schemas:httpmail:messageflag IS NULL" 
 
 Const strS As String = "Inbox" 
 
 Dim rsts As Outlook.Results 
 
 Dim i As Integer 
 
 blnSearchComp = False 
 
 Const strF1 As String = "urn:schemas:mailheader:subject = 'Test'" 
 
 Const strS1 As String = "Inbox" 
 
 Set objSch = _ 
 
 Application.AdvancedSearch(Scope:=strS1, Filter:=strF1, Tag:="FlagSearch") 
 
 While blnSearchComp = False 
 
 DoEvents 
 
 Wend 
 
 Set rsts = objSch.Results 
 
 For i = 1 To rsts.Count 
 
 MsgBox rsts.Item(i).SenderName 
 
 Next 
 
End Sub

另請參閱

搜尋物件

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。