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 WithEnd Sub以上即是VBA代码,运行后自动将D盘根目录下的文件名称和相关时间属性填写在Sheet1中,见下图效果: