V

【VBA】遍历文件夹下所有的文件夹名称

肉松 笔记 2021-08-09
Option Explicit
Sub 提取文件夹名称()
Dim fs As Object
Dim f As Object
Dim fd As Object
Dim n As Integer
n = 2              '变量起始行
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.getfolder("C:\Users\合同\未整理")    '指定目录
For Each fd In f.subfolders
Cells(n, 2) = fd.Name
n = n + 1
Next
Set f = Nothing
Set fs = Nothing
End Sub
PREV
打印机扫描仪【使用该设备需要VIA驱动程序 请从安装CD…】&WIA服务1061错误
NEXT
Excel、VBA与MySQL交互

评论(0)

发布评论