[英]Export each slide of Powerpoint to a separate pdf file
I need to generate for each slide of my presentation a pdf file.我需要为演示文稿的每张幻灯片生成一个 pdf 文件。
I'm using the following code:我正在使用以下代码:
ActivePresentation.ExportAsFixedFormat ActivePresentation.Path & "\" & ActivePresentation.Name & ".pdf", ppFixedFormatTypePDF, ppFixedFormatIntentPrint
This code works fine, but it exports all the slides into a unique pdf file.此代码工作正常,但它将所有幻灯片导出为唯一的 pdf 文件。
You can do that: Below code will create pdf with adding the slide number at end of current folder, file name.您可以这样做:下面的代码将创建 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
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
I added an OpenFileDialogPicker, so you can choose the wishen location by yourself我添加了一个OpenFileDialogPicker,所以你可以自己选择愿望位置
For me, the the accepted answer doesn't work.对我来说,接受的答案不起作用。 Also tried the fix suggested in the comment.
还尝试了评论中建议的修复。 Probably because I'm on Mac or sth.
可能是因为我在使用 Mac 或 sth。
I found this alternative question/answer which I tweaked to save each slide separately:我找到了这个替代问题/答案,我对其进行了调整以分别保存每张幻灯片:
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
我发现了一种快速/简单的方法,可以将 ppt 演示文稿中的单个幻灯片保存为单独的 pdf 文件……没什么特别的……只需几步……(1)右键单击幻灯片(如左侧所示) -hand 栏),选择 COPY (2) 左键单击左下角的“开始”按钮并重新打开 PowerPoint 程序到空白页 (3) 右键单击该空白文档并点击“粘贴”(您可能有一个额外的空白页)在顶部,只需右键单击并剪切以摆脱它)(4)文件/另存为/(选择)PDF 重复每张幻灯片的步骤
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.