由于您经常这样做,因此您应该为此制作一个加载项。这个想法是创建演示文稿的副本,其中的部分数量最多,然后打开每个部分并删除其他部分并保存。
- 创建启用宏 (*.pptm) 的空白演示文稿,并可能添加自定义 UI 按钮以调用
SplitIntoSectionFiles
- 测试并满足时,另存为 PowerPoint Add-In (*.ppam)。不要删除 pptm 文件!
假设你正在处理的都是 pptx 文件,你可以使用这段代码。它在后台打开拆分的 pptx 文件,然后删除不相关的部分并保存,关闭。如果一切顺利,您会收到一个消息框。
Private Const PPT_EXT As String = ".pptx"
Sub SplitIntoSectionFiles()
On Error Resume Next
Dim aNewFiles() As Variant, sPath As String, i As Long
With ActivePresentation
sPath = .Path & "\"
For i = 1 To .SectionProperties.Count
ReDim Preserve aNewFiles(i)
' Store the Section Names
aNewFiles(i - 1) = .SectionProperties.Name(i)
' Force Save Copy as pptx format
.SaveCopyAs sPath & aNewFiles(i - 1), ppSaveAsOpenXMLPresentation
' Call Sub to Remove irrelevant sections
RemoveOtherSections sPath & aNewFiles(i - 1) & PPT_EXT
Next
If .SectionProperties.Count > 0 And Err.Number = 0 Then MsgBox "Successfully split " & .Name & " into " & UBound(aNewFiles) & " files."
End With
End Sub
Private Sub RemoveOtherSections(sPPT As String)
On Error Resume Next
Dim oPPT As Presentation, i As Long
Set oPPT = Presentations.Open(FileName:=sPPT, WithWindow:=msoFalse)
With oPPT
' Delete Sections from last to first
For i = .SectionProperties.Count To 1 Step -1
' Delete Sections that are not in the file name
If Not InStr(1, .Name, .SectionProperties.Name(i), vbTextCompare) = 1 Then
' Delete the Section, along with the slides associated with it
.SectionProperties.Delete i, True
End If
Next
.Save
.Close
End With
Set oPPT = Nothing
End Sub
如果您没有创建自己的功能区选项卡的经验,请阅读自定义 UI:msdn并使用“Office 自定义 UI 编辑器”,我将使用 imageMso“CreateModule”作为按钮。