I need to generate for each slide of my presentation a pdf file.
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.
You can do that: Below code will create pdf with adding the slide number at end of current folder, file name.
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
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.
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 重复每张幻灯片的步骤
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.