- Dim srcDir, dstDir, fso, objApp
-
- srcDir = "D:\Test"
- dstDir = "E:\Temp"
-
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set objApp = CreateObject("PowerPoint.Application")
- objApp.Visible = True
-
- Call EnumFiles(srcDir)
-
- objApp.Quit
- Set objApp = Nothing : Set fso = Nothing
-
- Function EnumFiles(strPath)
- Dim objFile, strExt, arr, strNewFile, objFolder
- For Each objFile In fso.GetFolder(strPath).Files
- strExt = fso.GetExtensionName(objFile.Path)
- If LCase(Left(strExt, 3)) = "ppt" Then
- strNewFile = Replace(objFile.Path, srcDir, dstDir, 1, 1, 1)
- arr = Split(strNewFile, "\")
- If UBound(arr) > 1 Then Call CreateSubFolder(arr)
- Call SaveFile(objFile.Path, strNewFile)
- End If
- Next
-
- For Each objFolder In fso.GetFolder(strPath).SubFolders
- Call EnumFiles(objFolder.Path)
- Next
- End Function
-
- Function CreateSubFolder(ByVal arr)
- Dim i, strSubFolder
- strSubFolder = arr(0)
- For i = 1 To UBound(arr) - 1
- strSubFolder = strSubFolder & "\" & arr(i)
- If Not fso.FolderExists(strSubFolder) Then fso.CreateFolder(strSubFolder)
- Next
- End Function
-
- Function SaveFile(strFile, ByVal strNewFile)
- Dim objPres
- Set objPres = objApp.Presentations.Open(strFile, false, false, false)
- objPres.SaveAs(strNewFile)
- objPres.Close
- Set objPres = Nothing
- End Function
复制代码
|