Sub GetFileTime() Dim i As Integer i = 1 Set fso = CreateObject("Scripting.FileSystemObject") Set fs = fso.getfolder("d:\.").Files With Sheet1 .Cells(1, 1) = "序號(hào)": .Cells(1, 2) = "創(chuàng)建時(shí)間": .Cells(1, 3) = "最后修改時(shí)間": .Cells(1, 4) = "最后訪問(wèn)時(shí)間" 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代碼,運(yùn)行后自動(dòng)將D盤根目錄下的文件名稱和相關(guān)時(shí)間屬性填寫在Sheet1中,見下圖效果: