标签:logs info this vba get folders debug efi 报表
Dim Dic As Object Sub GetFileName() Dim FolderPath As String Set Dic = CreateObject("Scripting.Dictionary") FolderPath = ThisWorkbook.Path & Application.PathSeparator & "2011年报表" RecursionFolder FolderPath Set Rng = ThisWorkbook.Worksheets(1).Range("A1") Rng.Resize(Dic.Count, 1).Value = Application.WorksheetFunction.Transpose(Dic.Items) End Sub Sub RecursionFolder(ByVal FolderPath As String) Dim Fso As Object Dim MainFolder As Object Dim OneFolder As Object Dim OneFile As Object Dim Index As Long Set Fso = CreateObject("Scripting.FileSystemObject") Set MainFolder = Fso.GetFolder(FolderPath) If MainFolder.Files.Count > 0 Then For Each OneFile In MainFolder.Files Index = Dic.Count + 1 Dic(Index) = OneFile.Name Debug.Print Index; OneFile.Name Next End If For Each OneFolder In MainFolder.SubFolders RecursionFolder OneFolder.Path Next Set Fso = Nothing Set MainFolder = Nothing End Sub
20170906xlVBA_RecursionGetFiles
标签:logs info this vba get folders debug efi 报表
原文地址:http://www.cnblogs.com/nextseven/p/7486836.html