filesearch只在03及以下版本的office才能用,高级的版本一般都用Dir函数遍历文件夹
所以我已经没法测试这段代码了,我只能写出来给你,对错无法保证
Sub Test()
Dim i As Integer
Dim strPath As String
strPath = ThisWorkbook.Path
With Application.FileSearch
.LookIn = strPath
.SearchSubFolders = True
.Filename = "*.*"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
arr = Split(.FoundFiles(i), "\")
brr = Split(UBound(arr), ".")
Range("A" & i) = brr(LBound(brr))
Next i
End If
End With
End Sub
'就是把For循环里面替换一下
用Dir直接就是文件名