下面的VBA代码功能是,获取指定位置的文件的最后的修改时间。
With Application.FileSearch
.NewSearch
.LookIn = "F:/ttt"
.Filename = "*.xls"
.SearchSubFolders = True
.FileType = msoFileTypeAllFiles
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Worksheets("sheet3").Cells(i, 2).Value = .FoundFiles(i)
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(.FoundFiles(i))
s = "Created: " & f.DateCreated
Worksheets("sheet3").Cells(i, 3).Value = s
Set f = Nothing
Set fs = Nothing
Next i
Else
MsgBox "文件未能找到!"
End If
End With