将Powerpoint的每张幻灯片导出到单独的pdf文件

时间:2013-07-29 16:21:58

标签: vba powerpoint powerpoint-vba

我需要为演示文稿的每张幻灯片生成一个pdf文件。

我正在使用以下代码:

ActivePresentation.ExportAsFixedFormat ActivePresentation.Path & "\" & ActivePresentation.Name & ".pdf", ppFixedFormatTypePDF, ppFixedFormatIntentPrint

此代码工作正常,但它会将所有幻灯片导出为唯一的pdf文件。

3 个答案:

答案 0 :(得分:2)

你可以这样做: 下面的代码将创建pdf,并在当前文件夹的末尾添加幻灯片编号,文件名。

Sub ExportSlidesToIndividualPDF()
Dim oPPT As Presentation, oSlide As Slide
Dim sPath As String, sExt As String

Set oPPT = ActivePresentation
sPath = oPPT.FullName & "_Slide_"
sExt = ".pdf"

For Each oSlide In oPPT.Slides
    i = oSlide.SlideNumber
    oSlide.Select
    oPPT.ExportAsFixedFormat _
        Path:=sPath & i & sExt, _
        FixedFormatType:=ppFixedFormatTypePDF, _
        RangeType:=ppPrintSelection
Next
Set oPPT = Nothing
End Sub

答案 1 :(得分:0)

Sub ExportSlidesToIndividualPDF()
Dim oPPT As Presentation, oSlide As Slide
Dim sPath As String, sExt As String
Dim dlgOpen As FileDialog
Set oPPT = ActivePresentation

timestamp = Now()
sExt = ".pdf"

With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = -1 Then ' if OK is pressed
sPath = .SelectedItems(1)

With dlgOpen

For Each oSlide In oPPT.Slides
    i = oSlide.SlideNumber
    oSlide.Select
    oPPT.ExportAsFixedFormat _
    Path:=sPath & "\" & Format(timestamp, "yyyymmdd") & "_" & "Slide#" & i & sExt, _
    FixedFormatType:=ppFixedFormatTypePDF, _
    RangeType:=ppPrintSelection
Next

End With
End If

End With
Set oPPT = Nothing
End Sub   

我添加了一个OpenFileDialogPicker,因此您可以自己选择希望的位置

答案 2 :(得分:-1)

我发现了一种快速/简单的方法,可以将ppt演示文稿中的单个幻灯片保存为单独的pdf文件......没什么特别的......只需几步...... (1)右键单击幻灯片(如左侧列中所示),选择COPY (2)左键单击左下角的“开始”按钮,然后将PowerPoint程序重新打开到空白页面 (3)右键单击该空白文档并单击粘贴(您可能在顶部有一个额外的空白页面,只需右键单击并将其剪切即可除去它) (4)文件/另存为/(选择)PDF 重复每张幻灯片的步骤