|
- Sub FilesCopy()
- Dim strPathSrc As String
- Dim strPathDest As String
- Dim l As Long
- Dim strFilename As String
- Set clg = New Collection
- strPathSrc = ThisWorkbook.Path & Application.PathSeparator & "文件"
- strPathDest = ThisWorkbook.Path & Application.PathSeparator & "复制" & Application.PathSeparator
- On Error Resume Next
- MkDir strPathDest
- Call fso(strPathSrc, "*.xls")
- For l = 1 To clg.Count
- strFilename = clg.Item(l)
- FileCopy strFilename, strPathDest & Mid(strFilename, InStrRev(strFilename, "") + 1)
- Next
- End Sub
- Sub fso(ByVal sPath As String, ByVal strPatterm As String)
- Dim fs As Object
- Dim fd As Object
- Dim fc As Object
- Dim s As Object, d As Object
- Set fs = CreateObject("scripting.filesystemobject")
- Set fd = fs.getfolder(sPath)
- Set fc = fd.Files
- For Each s In fc
- If UCase(s.Name) Like UCase(strPatterm) And s.Name <> ThisWorkbook.Name Then clg.Add s.Path
- Next
- For Each d In fd.SubFolders
- Call fso(d.Path, strPatterm)
- Next
- End Sub
复制代码 |
评分
-
查看全部评分
|