これは頻繁に行うため、このためのアドインを作成する必要があります。アイデアは、プレゼンテーションのセクションの数までプレゼンテーションのコピーを作成し、それぞれを開いて他のセクションを削除して保存することです。
- マクロを有効にして空白のプレゼンテーション (*.pptm) を作成し、カスタム UI ボタンを追加して呼び出します。
SplitIntoSectionFiles
- テストして満足したら、PowerPoint アドイン (*.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 エディター」を使用します。