我想将特定文件夹中每个文件的文件大小写入Excel。我怎么能这样做?
答案 0 :(得分:1)
您可以使用FileSystemObject对象来处理文件,文件夹和文本流:
''Reference: Windows Script Host Object Model
Dim fs As New FileSystemObject
Dim fldr As Folder
Dim f As File
Dim i As Integer
Set fldr = fs.GetFolder("C:\docs\")
With ActiveWorkbook.Sheets("Sheet3")
i = 1
For Each f In fldr.Files
.Cells(i, 1) = f.Name
.Cells(i, 2) = f.Size
i = i + 1
Next
End With
答案 1 :(得分:0)
由于您没有提及有关编程的任何内容,我认为这属于SuperUser,但您只需要选择所有文件,右键单击,选择“属性”,然后复制“大小”。