2012年11月27日 星期二
用vba讀取在同一資料夾內檔案及其資訊 , 寫在即時運算視窗內
Option Explicit
Sub Get_file_info()
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
For Each myFile In myFiles
With myFile
Debug.Print "製作日:" & .DateCreated
Debug.Print "最後存取日:" & .DateLastAccessed
Debug.Print "最後更新日:" & .DateLastModified
Debug.Print "Root磁碟機名:" & .Drive
Debug.Print "檔案名稱:" & .Name
Debug.Print "上層資料夾名稱:" & .ParentFolder
Debug.Print "路徑:" & .Path
Debug.Print "DOS用短名稱:" & .ShortName
Debug.Print "DOS用短路徑:" & .ShortPath
Debug.Print "大小:" & (.Size / 1024) & "KB"
Debug.Print "類型:" & .Type
End With
Next
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言