Solution: by VBA file list list under the specified file path, and through a one-dimensional array stored file name, file extensions, list of child folders can be obtain by means of recursive calls file list, and then as a condition of judgment, depending on the type of the file to open a file type for subsequent processing, such as the textual substitution, etc., under the given folder traversal process code:
Sub GetAllFiles (ByVal RecepPath As String) 'get files list
Dim Mainfolder SubFolder, File_Currentfolder As Object
On the Error Resume Next
The Set Mainfolder=FS. Getfolder (RecepPath)
For Each File_Currentfolder In Mainfolder. Files
FilesList_i=FilesList_i + 1
If Right (RecepPath, 1) & lt;> "" Then
RecepPath=RecepPath & amp; ""
End the If
FilesList (FilesList_i, 1)=RecepPath & amp; File_Currentfolder. Name
FilesNameList (FilesList_i, 1)=FS. Getbasename (File_Currentfolder)
FileExtNameList (FilesList_i, 1)=FS. Getextensionname (File_Currentfolder)
Next
For Each SubFolder In Mainfolder. Subfolders
Call GetAllFiles (SubFolder. Path)
Next
End Sub
CodePudding user response:
This is to ask questions? Or ask the answer?CodePudding user response:
The couple said look not to understand ah ~ ~CodePudding user response:
Baidu, you knowCodePudding user response:
Look not very know what you mean, but the following code can extract all files folder name, and then you according to the requirements accordingly processingSub extract all the filename () within a specified folder 'file containing all subfolders within
Dim Fso As Object, arrf $(), mf&
The Set of Fso=CreateObject (" Scripting. FileSystemObject ")
Call GetFiles (CreateObject (" Shell. Application "). BrowseForFolder (0, "please select a folder," 0, "mypath"). The Self. The Path, Fso, arrf, mf)
[a2]. Resize (mf)=Application. The Transpose (arrf)
The Set of Fso=Nothing
MsgBox (" reads ")
End Sub
CodePudding user response:
The