VBA/Excel/Access/Word/Application/Application.FileSearch — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:46, 26 мая 2010

Find files

 
Sub findFile()
   With Application.FileSearch
        .NewSearch
        .LookIn = "c:\BegVBA"
        .FileName = "store.mdb"
        .SearchSubFolders = True
            If .Execute() > 0 Then
               msgBox "The file " & .FoundFiles(1) & " was found"
             Else
                msgBox "The file is not found"
            End If
    End With
End Sub



Find file with wild character

 
Sub findFile()
       Dim i As Integer
       With Application.FileSearch
            .NewSearch
            .LookIn = "c:\"
            .FileName = "*.mdb"
            .SearchSubFolders = True
                If .Execute() > 0 Then
                   For i = 1 To .FoundFiles.count
                     Debug.Print .FoundFiles(i)
                   Next i
                End If
        End With
End Sub