Just found out about FSO while looking for ways to import files names from folders/subfolders into access.
and I wanted to know if it is possible to change the Debug.Print fl.Name to populate a table with the results instead of populating the immediate window. (I did add the required Microsoft Scripting Runtime referance so it will run as it is)
And a second question, is it possible to put something like a WHERE criteria on this to only check for some specific text in the returned results.
Below is some code that I am playing with, it was copied from: http://www.ezidata.com.au/Tutorials/Working_with_Files.html
and I wanted to know if it is possible to change the Debug.Print fl.Name to populate a table with the results instead of populating the immediate window. (I did add the required Microsoft Scripting Runtime referance so it will run as it is)
And a second question, is it possible to put something like a WHERE criteria on this to only check for some specific text in the returned results.
Below is some code that I am playing with, it was copied from: http://www.ezidata.com.au/Tutorials/Working_with_Files.html
Code:
Private Sub FSO_Test_Click()
'declare the starting or root folder – you could get this from the Drives
Dim strRoot As String
strRoot = "C:\Silly folder names\Cat pictures to caption\If actions are louder than words then what language do they speak\I saw jesus in a llama"
'declare the variables for use with the Scripting library
Dim fso As New Scripting.FileSystemObject
Dim parent As Scripting.Folder
Dim children As Scripting.Folders
Dim child As Scripting.Folder
Dim fl As File
'get the folder from fso
Set parent = fso.GetFolder(strRoot)
'get the subfolders contained within the root folder
Set children = parent.SubFolders
'iterate through the subfolder under the root and display some data
For Each child In children
'iterate through the files
For Each fl In child.Files
Debug.Print fl.Name
Next
Next
End Sub