I need to get a collection of file names from a folder on a remote server using VBA in excel 2010. I have a function that works and in the majority of cases it would do the
This one is lightning fast:
Sub filesTest()
Dim x() As String
x = Function_FileList("YOUR_PATH_AND_FOLDER_NAME")
Debug.Print Join(x, vbCrLf)
End Sub
Which calls this function:
Function Function_FileList(FolderLocation As String)
Function_FileList = Filter(Split(CreateObject("wscript.shell").exec("cmd /c Dir """ & FolderLocation & """ /b /a-d").stdout.readall, vbCrLf), ".")
End Function