二楼的少了个引号,呵呵...- Option Explicit
-
- Dim objFSO, strPath, objFolder, objFile
- strPath = "d:\"
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objFolder = objFSO.getfolder(strPath)
- Call GetAllFolders(objFolder)
- For Each objFile In objFolder.Files
- If objFSO.GetExtensionName(objFile.Name) = "pdf" Then
- objFSO.GetFile(objFile).Copy ("e:\123\") '这里少了个引号,汗...
- End If
- Next
- Set objFSO = Nothing
- Set objFolder = Nothing
-
- Sub GetAllFolders(Folder)
- Dim SubFolder, objFile, objFSO
- Set objFSO = CreateObject("scripting.filesystemobject")
- For Each SubFolder In Folder.SubFolders
- For Each objFile In SubFolder.Files
- If objFSO.GetExtensionName(objFile.name) = "pdf" Then
- objFSO.GetFile(objFile).Copy ("e:\123\")
- End If
- Next
- Call GetAllFolders(SubFolder)
- Next
- Set objFSO = Nothing
- End Sub
复制代码
|