Is there a way to capture all of the files for a given
directory? I will then write these file names and some
selected attributes of the files to a table.
This writes the names of the files to a List Box Row Source.
Adapt it to write to a table.
Public Sub GetFileNames()
' This will fill a list box with all of the file names in a Folder.
On Error GoTo Err_Handler
Dim intX As Integer
Dim MyPath As String, MyName As String
' Display the names in C:\ that represent directories.
MyPath = "c:\FolderName\"
MyName = Dir(MyPath, vbDirectory)
Do While MyName <> "" ' Start the loop.
intX = 1
If MyName = "." Or MyName = ".." Then
Else
List241.RowSource = List241.RowSource & MyName & ","
End If
MyName = Dir ' Get next file.
Loop
List241.RowSource = Left(List241.RowSource, Len(List241.RowSource) -
1)
If intX = 0 And MyName = "" Then MsgBox "Nothing found"
Exit_Sub:
Exit Sub
Err_Handler:
MsgBox "Error # " & Err.Number & vbCrLf & Err.Description
Resume Exit_Sub
End Sub