|
こんにちは。
Next Folderで次のフォルダ―に移る時、
貼付行 = 0に初期化してしまうでしょうか?
何故だか、次のフォルダ―に移ると、またsheetの1行目から書いてしまいます。
Sub Sample()
Call FileSearch("C:\_cosmos\Tr")
End Sub
Sub FileSearch(Path As String)
Dim FSO As Object, Folder As Variant, File As Variant
Set FSO = CreateObject("Scripting.FileSystemObject")
貼付行 = 0
For Each Folder In FSO.GetFolder(Path).SubFolders
Call FileSearch(Folder.Path)
For Each File In FSO.GetFolder(Path).Files
' Debug.Print File.Path
貼付行 = 貼付行 + 1
Cells(貼付行, 1).Value = File.Path
Next File
Next Folder
End Sub
|
|