列出同目錄下 Excel 檔案資料 http://cat14051.mysinablog.com/index.php?op=ViewArticle&articleId=124599

'---------------------------------------------------------------------------------------
' Module : Module1
' DateTime : 14/3/2006 21:55
' Author : Emily
' Purpose : List Files information in Current WorkBook Path
'---------------------------------------------------------------------------------------

Option Explicit
Sub FilesInfo()
' Set reference to Microsoft Scripting Runtime
Dim x As Integer
Dim myFso As Scripting.FileSystemObject
Dim myFiles As Scripting.Files
Dim myFile As Scripting.File
Set myFso = New Scripting.FileSystemObject
Set myFiles = myFso.GetFolder(ThisWorkbook.Path).Files
x = 2
With Sheet1
Cells(1, 1) = "檔案名稱"
Cells(1, 2) = "製作日"
Cells(1, 3) = "最後存取日"
Cells(1, 4) = "最後更新日"
Cells(1, 5) = "大小 (Kb)"
For Each myFile In myFiles
If myFso.GetExtensionName(Path:=myFile) = "xls" Then
With myFile
Cells(x, 1) = .Name
Cells(x, 2) = .DateCreated
Cells(x, 3) = .DateLastAccessed
Cells(x, 4) = .DateLastModified
Cells(x, 5) = (.Size / 1024)
x = x + 1
End With
End If
Next
Columns("A:E").EntireColumn.AutoFit
End With
Set myFiles = Nothing
Set myFso = Nothing
End Sub
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 YOUNG21975 的頭像
    YOUNG21975

    YOUNG21975

    YOUNG21975 發表在 痞客邦 留言(1) 人氣()