Search Scope Object and Scope Folder Object

A SearchScope object denotes a type of folder that can be searched by using the FileSearch object. Each local or network drive, and even a Microsoft Outlook folder on your computer, represents a single search scope. Search scope types are represented by the following constants: msoSearchInMy-Computer, msoSearchInMyNetworkPlaces, msoSearchInOutlook, and msoSearchInCustom. Within each SearchScope object, there is a single ScopeFolder object that corresponds to the root folder of the search scope. A ScopeFolder represents a searchable folder and is part of a SearchFolders collection. Use the SearchFolders collection to define the folders to search when using the FileSearch object. The following procedure lists all searchable folders on your computer:

Sub SearchableFolders()

Dim objSScope As SearchScope Dim objSFolder As ScopeFolder Dim strPaths As String

With Application.FileSearch

For Each objSScope In .SearchScopes Select Case objSScope.Type Case msoSearchInMyComputer

For Each objSFolder In objSScope. _ ScopeFolder.ScopeFolders strPaths = strPaths & objSFolder.Path & vbCrLf

Next Case Else End Select Next objSScope End With

MsgBox "The following paths are searchable:" & vbCrLf & strPaths Debug.Print strPaths

End Sub

0 0

Post a comment