2

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

我正在使用以下代码:

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

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

4

4 回答 4

5

你可以这样做:下面的代码将创建 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
于 2013-07-31T06:47:39.587 回答
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,所以你可以自己选择希望的位置

于 2019-09-26T10:54:59.753 回答
0

对我来说,接受的答案不起作用。还尝试了评论中建议的修复。可能是因为我在Mac或某事上。

我找到了这个替代问题/答案,我对其进行了调整以分别保存每张幻灯片:

Sub each_slide_to_separate_pdf()

  'Hide all slides
  For i = 1 To ActivePresentation.Slides.Count
     ActivePresentation.Slides(i).SlideShowTransition.Hidden = msoTrue
  Next i

  'display each slide and save
  For i = 1 To ActivePresentation.Slides.Count
    'display current slide
    ActivePresentation.Slides(i).SlideShowTransition.Hidden = msoFalse

    'Save location
    Dim filePath As String
    filePath = "/Users/username/Documents/vba_folder" & i & "slide.pdf"
    ActivePresentation.SaveAs filePath, ppSaveAsPDF
    
    'hide the just saved slide
    ActivePresentation.Slides(i).SlideShowTransition.Hidden = msoTrue
  Next i

 'Show all slides again
 For i = 1 To ActivePresentation.Slides.Count
    ActivePresentation.Slides(i).SlideShowTransition.Hidden = msoFalse
 Next i

End Sub
于 2021-11-09T14:56:53.940 回答
-1

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

于 2015-03-19T21:47:50.330 回答