|
楼主 |
发表于 2013-8-5 15:52
|
显示全部楼层
Dj_soo 发表于 2013-8-5 13:46
哦..才注意看你的代码,你没有进行转置啊亲..
arr定义为arr(1 to xx,1 to 1)
忘了转置,悲哀 。。。改了
Dim FSO As Object, arr(1 To 10 ^ 7, 1 To 1), i
'主程序
Sub test1()
Set FSO = CreateObject("scripting.filesystemobject")
test2 "f:\Downloads"
Cells.Clear
If i Then [a1].Resize(i, 1) = arr
End Sub
'
Sub test2(MyPath As String)
Dim Folder As Object, SubFolder As Object
Dim FileCollection As Object, FileName As Object
'
Set Folder = FSO.getfolder(MyPath)
Set FileCollection = Folder.Files
For Each FileName In FileCollection
i = i + 1: arr(i, 1) = FileName
Next
'
For Each SubFolder In Folder.SubFolders
test2 SubFolder.Path
Next
End Sub
|
|