VBA/Excel/Access/Word/File Path/FileDateTime

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

Displaying a list of files in a directory

 
Sub ListFiles2()
    
    With Application.fileSearch
        .NewSearch
        .LookIn = "c:\windows\desktop\"
        .FileName = "*.*"
        .SearchSubFolders = False
        .Execute
        For i = 1 To .FoundFiles.Count
            Debug.Print .FoundFiles(i)
            Debug.Print FileLen(.FoundFiles(i))
            Debug.Print FileDateTime(.FoundFiles(i))
        Next i
    End With
End Sub



FormatDateTime(Now, vbGeneralDate)

 
Sub dateFunctions()
    Debug.Print "vbGeneralDate: " & FormatDateTime(Now, vbGeneralDate)
End Sub



FormatDateTime(Now, vbLongDate)

 
Sub dateFunctions()
    Debug.Print "vbLongDate: " & FormatDateTime(Now, vbLongDate)
End Sub



FormatDateTime(Now, vbShortDate)

 
Sub dateFunctions()
    Debug.Print "vbShortDate: " & FormatDateTime(Now, vbShortDate)
End Sub



Retrieve Date and Time of Last Save

 
Sub LastSaved() 
    Debug.Print FileDateTime("C:\")
End Function