|
- Sub GetFiles()
- Dim Fso, fds, fd, folser1, folder2, fs, f, mypath$, myname$
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- mypath = Replace(ThisWorkbook.Path, "\提取到这文件夹里", "")
- Set Fso = CreateObject("Scripting.FileSystemObject")
- Set folder1 = Fso.GetFolder(mypath) '获得文件夹
- Set fds = folder1.SubFolders '子文件夹集合
- For Each fd In fds '遍历子文件夹
- If fd.Name <> "提取到这文件夹里" Then
- Set folder2 = fd '获得文件夹2
- Set fs = folder2.Files '文件集合
- For Each f In fs '遍历文件
- If InStr(f.Name, Cells(1, 5).Value) Then
- FileCopy mypath & "" & fd.Name & "" & f.Name, mypath & "\提取到这文件夹里" & f.Name
- End If
- Next
- End If
- Next
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|