Método RefreshScopes

Microsoft Office Objects

Método RefreshScopes

       

Actualiza la lista de objetos ScopeFolder disponibles actualmente.

expresión.RefreshScopes

expresión   Requerida. Expresión que devuelve uno de los objetos de la lista Aplicar a.

Ejemplo

El ejemplo siguiente muestra todos los objetos ScopeFolder disponibles actualmente en la unidad C:\ del ámbito de Mi PC.

Sub TestRefreshScopesMethod()
' Displays what happens before and after the RefreshScopes
' method is called when a new folder is added to the list
' of scope folders.

    ' List before the folder is created.
    Call ListFolderNames
    
    ' Create a new folder on the C:\ drive in My Computer.
    ' An error will occur if this folder already exists.
    MkDir Path:="C:\Delete_After_Using"
    
    ' List after the folder is created.
    Call ListFolderNames
    
    ' Refresh the list of folders.
    Application.FileSearch.RefreshScopes
    
    ' The newly-created folder now appears in the list.
    Call ListFolderNames
    
End Sub

Sub ListFolderNames()

    Dim strResults As String
    
    ' Loop through all the folder names on the C:\ drive
    ' in My Computer and report the results.
    ' .SearchScopes.Item(1) = "My Computer"
    ' .ScopeFolders.Item(2) = "C:\"
    With Application.FileSearch.SearchScopes.Item(1). _
        ScopeFolder.ScopeFolders.Item(2)
        
        For i = 1 To .ScopeFolders.Count
            strResults = strResults & .ScopeFolders. _
                Item(i).Name & vbCrLf
        Next i
        
        MsgBox "Folder Names on C:\...." & vbCrLf & strResults
    
    End With
    
End Sub