This should work for you. You will need to add a reference to the Microsoft Scripting Runtime from the Project Menu.
Option Explicit
'Requires Reference to the Microsoft Scripting Runtime
Dim fso As New FileSystemObject
Dim arrFiles() As String
Private Sub Command1_Click()
Dim fFolder As Folder
Dim fFile As File
Dim iX As Long
Dim sPath As String
sPath = "C:\Test" 'Path of Directory
Set fFolder = fso.GetFolder(sPath)
For Each fFile In fFolder.Files
ReDim Preserve arrFiles(iX)
arrFiles(iX) = fFile.Name
iX = iX + 1
Next
End Sub
Hope this helps.
If you choose to battle wits with the witless be prepared to lose.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.