-
I would like to list the filenames of all files in "C:\My Documents"
How do I do this?
I can count them with this but I need to list their names.'count files in a directory
Dim iFiles As Integer
Dim sDir As String
sDir = Dir("C:\My Documents\*.*", vbNormal)
While sDir <> ""
iFiles = iFiles + 1
sDir = Dir
Wend
-
Add something like MsgBox "The name of file number " & iFiles & " is " & sDir after the iFiles = iFiles + 1 line.
------------------
Marty
-
i think you would do something like this...
Dim iFiles As Integer
Dim sDir As String
sDir = Dir("C:\My Documents\*.*", vbNormal)
While sDir <> ""
'if youwant to keep count...
iFiles = iFiles + 1
'to add them to a listbox
List1.Additem sDir
sDir = Dir
Wend
--michael
-
why don't you use the file control "FileListBox"?
e.g.
File1.Path = "C:\My Documents"
-
Thank you all..
I have it.