如何用VBA遍历指定目录下的所有子文件夹和文件
答案:1 悬赏:20 手机版
解决时间 2021-02-12 20:32
- 提问者网友:眉目添风霜
- 2021-02-12 00:14
如何用VBA遍历指定目录下的所有子文件夹和文件
最佳答案
- 五星知识达人网友:轮獄道
- 2021-02-12 01:29
Sub 文件夹内遍历法()
Dim arr, n&, i&, j&, s$, sh
Dim myPath$, myFile$
Dim cnn As Object, rs As Object, wb As Workbook
myPath = ThisWorkbook.Path & "\"
myFile = Dir(myPath & "*.xlsm")
n = CreateObject("Scripting.FileSystemObject").GetFolder(myPath).Files.Count - 1
ReDim arr(1 To 1000, 1 To n)
Do While myFile <> ""
If myFile <> ThisWorkbook.Name Then
Set wb = myFile.Sheets
End If
myFile = Dir
Loop
Range("A1").Resize(j, i) = arr '输出
End Sub
Dim arr, n&, i&, j&, s$, sh
Dim myPath$, myFile$
Dim cnn As Object, rs As Object, wb As Workbook
myPath = ThisWorkbook.Path & "\"
myFile = Dir(myPath & "*.xlsm")
n = CreateObject("Scripting.FileSystemObject").GetFolder(myPath).Files.Count - 1
ReDim arr(1 To 1000, 1 To n)
Do While myFile <> ""
If myFile <> ThisWorkbook.Name Then
Set wb = myFile.Sheets
End If
myFile = Dir
Loop
Range("A1").Resize(j, i) = arr '输出
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯