|
发表于 2011-10-18 22:10
|
显示全部楼层
本楼为最佳答案
- Sub Test()
- Dim fs As Object, fld As Object, fil As Object, f As Object
- Dim p As String
- Dim arr() As Variant
- Dim i As Integer
- Cells.Clear
- Cells(1, 1) = "名称"
- Cells(1, 2) = "创建日期"
- Cells(1, 3) = "最后修改日期"
- Cells(1, 4) = "最后访问日期"
-
- p = "C:\WINDOWS"
- Set fs = CreateObject("Scripting.FileSystemObject")
- Set fld = fs.GetFolder(p)
- Set fil = fld.Files
- ReDim Preserve arr(1 To fil.Count, 1 To 4)
- For Each f In fil
- i = i + 1
- '设置或返回指定文件或文件夹名。读/写属性。
- arr(i, 1) = f.Name
- '返回指定文件或文件夹的创建日期和时间。只读。
- arr(i, 2) = f.DateCreated
- '返回最后一次修改指定文件或文件夹的日期和时间。只读。
- arr(i, 3) = f.DateLastModified
- '返回最后一次访问指定文件或文件夹的日期和时间。只读。
- arr(i, 4) = f.DateLastAccessed
- Next f
- Range("A2").Resize(UBound(arr), UBound(arr, 2)) = arr
- Range("A:D").EntireColumn.AutoFit
- End Sub
复制代码
比较实际问题,再修改吧 |
|