怎样批量获取文件的 “创建内容的时间、创建日期、修改日期”。最好能用VBA 或者变成EXCEL列表,求大神

2024-08-17 04:56:20
推荐回答(1个)
回答1:

Sub GetFileTime()
    Dim i As Integer
    i = 1
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fs = fso.getfolder("d:\.").Files
    With Sheet1
        .Cells(1, 1) = "序号": .Cells(1, 2) = "创建时间": .Cells(1, 3) = "最后修改时间": .Cells(1, 4) 液拦御= "最后访问时间"
        For Each f In fs
            i = i + 1
         衡渣   .Cells(i, 1) = f.Name: .Cells(i, 2) = f.datecreated: .Cells(i, 3) = f.DateLastModified: .Cells(i, 4) = f.DateLastAccessed
        Next
    End With
End Sub

以上即是VBA代码,运闹岩行后自动将D盘根目录下的文件名称和相关时间属性填写在Sheet1中,见下图效果: