2、VBA(2003版)
在那个文件夹下新建Excel文件,打开新建的Excel文件,右击工作表标签(如Sheet1),查看代码——在代码编辑器中输入以下代码
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
Range("A" & i) = .FoundFiles(i)
Next i
End If
End With
End Sub
回到Excel表格中,工具——宏——宏——选择Sheet1.Test——执行
看看效果吧!