Function GetFileNamesFromFolder(folderPath As String) As Collection
Dim fileNames As New Collection
Dim fso As Object ' FileSystemObject
Dim folder As Object ' Folder
Dim file As Object ' File
' Create a FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
' Get the folder object
Set folder = fso.GetFolder(folderPath)
' Loop through each file in the folder and add its name to the collection
For Each file In folder.Files
fileNames.Add file.Name
Next file
' Release the objects
Set file = Nothing
Set folder = Nothing
Set fso = Nothing
' Return the collection of file names
Set GetFileNamesFromFolder = fileNames
End Function