|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub DeleteLastSlide()
- Dim i&, j&, arr
- With Application.FileDialog(msoFileDialogFolderPicker)
- If .Show Then myPath$ = .SelectedItems(1) Else Exit Sub
- End With
- If Right(myPath, 1) <> "" Then myPath = myPath & ""
- Set d1 = CreateObject("Scripting.Dictionary")
- Set d2 = CreateObject("Scripting.Dictionary")
- d1(myPath) = ""
- Set fso = CreateObject("Scripting.FileSystemObject")
- Do While i < d1.Count
- kr = d1.Keys
- For Each f In fso.GetFolder(kr(i)).Files
- If f.Name Like "*.ppt*" Then
- j = j + 1: d2(j) = kr(i) & "" & f.Name
- End If
- Next
- i = i + 1
- For Each fd In fso.GetFolder(kr(i - 1)).SubFolders
- d1(fd.Path) = " " & fd.Name & ""
- Next
- Loop
- arr = d2.Items
- If (UBound(arr) < 0) Then
- MsgBox "当前目录下没有其它的PPT", 48, "警告"
- Exit Sub
- Else
- For i = 0 To UBound(arr)
- Set pptInput = Presentations.Open(arr(i), ReadOnly:=msoFalse)
- With Application.Presentations(arr(i)).Windows(1)
- If Not .Active Then
- Set oldWin = Application.ActiveWindow
- .Activate
- End If
- End With
- ActivePresentation.Slides(ActivePresentation.Slides.Count).Delete
- Presentations(arr(i)).Save
- Presentations(arr(i)).Close
- Next i
- End If
- End Sub
复制代码
|
|