


The code below uses the function above to get all the files in the folder: 'loops through each file in the directory and printsĪssume we have the following files in a folder: Set objFolder = objFSO.GetFolder(strPath) Set objFSO = CreateObject("Scripting.FileSystemObject") 'Create an instance of the FileSystemObject Private Function GetAllFilePaths( ByVal strPath As String) As String() It returns a string array with the path of all the files in the folder. The function below recieves as input the path of the folder. Find and List All Files and Folder in a DirectoryĪlthough that article was aimed for Excel, the concept can also be applied to VBA for Word.I have explained how this can be done in the article below: Get the list of all the file paths in the folder.
