我需要列出所有文件和特定文件夹的帮助。我使用了本教程,但无法使其与VBA一起使用。
一旦在一个驱动器上,这仍然可以工作吗?如果我按照没有VBA的教程进行操作,则该函数不会列出文件名...
请帮助我。
谢谢
VBA:
['[pid 30101] 04:15:46 getuid()', '[pid 30101] 04:15:46 getuid()', '[pid 30101] 04:15:46 getuid()']
单元格功能:
Function GetFileNames(ByVal FolderPath As String) As Variant
Dim Result As Variant
Dim i As Integer
Dim MyFile As Object
Dim MyFSO As Object
Dim MyFolder As Object
Dim MyFiles As Object
Set MyFSO = CreateObject("Scripting.FileSystemObject")
Set MyFolder = MyFSO.GetFolder(FolderPath)
Set MyFiles = MyFolder.Files
ReDim Result(1 To MyFiles.Count)
i = 1
For Each MyFile In MyFiles
Result(i) = MyFile.Name
i = i + 1
Next MyFile
GetFileNames = Result
End Function
A1:
=IFERROR(INDEX(GetFileNames($A$1),ROW()-2),"")
这实际上打印出来了
=REPLACE(CELL("filename"),FIND("[",CELL("filename")),LEN(CELL("filename")),"*")
我必须删除斜杠和*才能在本地工作。但仍然无法在一个驱动器上工作