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中,見下圖效果: