将 PowerPoint 部分导出到单独的文件中 [英] Exporting PowerPoint sections into separate files

查看:65
本文介绍了将 PowerPoint 部分导出到单独的文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每周我都会将一个很长的 PowerPoint 文件分成单独的文件.文件必须为 PowerPoint 格式,并且仅包含 PowerPoint 文件中部分"中包含的幻灯片.

Every week I separate a long PowerPoint file into separate files. The files must be in PowerPoint format, and contain only the slides that are contained in the 'sections' from the PowerPoint file.

我需要:
1) 扫描以查看给定部分中的幻灯片数量
2) 制作一个包含该部分中幻灯片的文件
3) 将该文件命名为与节的名称相同的名称,并将其保存在与源文件相同的目录中.
4) 对后续部分重复该过程.
5) 在不损坏原始文件的情况下执行此操作.

I need to:
1) Scan to see the number of slides in a given section
2) Make a file containing the slides within that section
3) Name that file the same as the name of the section, and save it in the same directory as the source file.
4) Repeat the process for subsequent sections.
5) Do this without damaging the original file.

我找到了代码 (http://www.pptfaq.com/FAQ01086_Break_a_presentation_up_into_several_smaller_presentations.htm">) 可以将文件分成许多部分,但仅限于每个文件请求的文件数.我在这里找到了一些其他有用的参考资料:http://skp.mvps.org/2010/ppt001.htm

我使用 Basic 和多种简单的游戏脚本语言编写代码.我需要帮助了解这是如何在 VBA 中完成的.

I have coded in Basic and a number of easy gaming scripting languages. I need help understanding how this is done in VBA.

推荐答案

由于您经常这样做,您应该为此创建一个 Add-In.这个想法是创建演示文稿的副本,最多包含其中的部分,然后打开每个部分并删除其他部分并保存.

Since you do this very often, you should make an Add-In for this. The idea is to create copies of the presentation up to the number of sections in it, then open each one and delete the other sections and save.

  1. 创建启用宏的空白演示文稿 (*.pptm) 并可能添加自定义 UI 按钮以调用 SplitIntoSectionFiles
  2. 测试并在满足时另存为 PowerPoint 插件 (*.ppam).不要删除 pptm 文件!

假设都是你处理的pptx文件,可以使用这段代码.它在后台打开拆分的pptx文件,然后删除不相关的部分并保存,关闭.如果一切顺利,您会收到一个消息框.

Assuming that all are pptx files you are dealing with, you can use this code. It opens the splited pptx files in background, then remove irrelevant sections and save, close. If all goes well you get a message box.

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 编辑器",我将使用 imageMsoCreateModule"作为按钮.

Read about Custom UI if you don't have experience creating you own ribbon tab: msdn and use the "Office Custom UI Editor", I would use imageMso "CreateModule" for the button.

这篇关于将 PowerPoint 部分导出到单独的文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆