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的更多相关文章

随机推荐

  1. topcoder srm 697 div1 -3

    1.给定长度为$n$ 的数组$b$,构造长度为$n$ 的且没有重复元素的数组$a$,令$p_{i}$表示$a$中除$a_{i}$外其他元素的乘积.构造出的$a$满足$a_{i}^{b_{i}}$能够被 ...

  2. Linux 搭建 Jenkins

    环境准备 安装JDK 安装 JDK 之前写过一篇文章,本文就不具体讲了: Linux 安装 JDK 注意:Java版本不能是gcj,会导致Jenkins有问题,centos7搭建jenkins小记文章 ...

  3. 【重新分配分片】Elasticsearch通过reroute api重新分配分片

    elasticsearch可以通过reroute api来手动进行索引分片的分配. 不过要想完全手动,必须先把cluster.routing.allocation.disable_allocation ...

  4. Android 设置app 启动

    首先建立一个Activity 类.然后他会自动生成一个Layout XML. 再去到AndroidManifest.xml <activity android:name="com.zx ...

  5. Tomcat和weblogic虚拟路径的配置

    背景:上传的图片和web应用不在同个路径里,例如web应用在D盘,上传图片1.jpg在E:\upload\img目录里,这时就需要配置虚拟路径后,才能显示图片. Tomcat和WebLogic的不同配 ...

  6. vue中使用BetterScroll

    BetterScroll可以通过给content加min-height实现永远滚动 content千万不可以删除,千万不要在 content上写v-if

  7. 重写NLog

    接口ILogBase: public interface ILogBase { void Debug(string message); void Debug(string message, Excep ...

  8. 洛谷P1244 青蛙过河 DP/思路

    又是一道奇奇怪怪的DP(其实是思路题). 原文戳>>https://www.luogu.org/problem/show?pid=1244<< 这题的意思给的挺模糊,需要一定的 ...

  9. printf和std::cout ...endl

    printf效率要比std::cout...endl高些,可以减少打印所花时间

  10. VHDL 例程

    以下程序未经仿真,仅供说明 语法 声明参考库ieee,使用ieee中的std_logic_1164包全部条目可见 library ieee; use ieee.std_logic_1164.all; ...