Use array to store a list of files : File « File Path « VBA / Excel / Access / Word






Use array to store a list of files

 
Sub XLFiles()
    Dim FName As String
    Dim arNames() As String
    Dim myCount As Integer
    
    FName = Dir("C:\*.xls*")
    Do Until FName = ""
        myCount = myCount + 1
        ReDim Preserve arNames(1 To myCount)
        arNames(myCount) = FName
        FName = Dir
    Loop

End Sub

 








Related examples in the same category

1.Does the specified file exist?
2.Check file existance
3.Gets the file name from the path.
4.List all files under application path
5.Select a folder
6.Select a location containing the files you want to list
7.processes multiple stored files
8.Common File Operations Simplified