vba 将 Powerpoint 的每张幻灯片导出为单独的 pdf 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17929124/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Export each slide of Powerpoint to a separate pdf file
提问by Renan Santos
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 文件。
回答by PatricK
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
回答by Ionyx Arts
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,所以你可以自己选择愿望位置
回答by SDL
I discovered a fast / easy way to save individual slides in a ppt presentation as separate pdf files...nothing fancy...just a few steps... (1) right-click on the slide (as it appears in the left-hand column), select COPY (2) Left-Click on your bottom left Start button and open the PowerPoint program anew to a blank page (3) Right-Click in that blank doc and hit Paste (you may have an extra blank page at the top, just right-click and Cut it to get rid of it) (4) File / Save As / (select) PDF REPEAT the steps for each slide
我发现了一种快速/简单的方法,可以将 ppt 演示文稿中的单个幻灯片保存为单独的 pdf 文件……没什么特别的……只需几步……(1)右键单击幻灯片(如左侧所示) -hand 栏),选择复制 (2) 左键单击左下角的“开始”按钮并重新打开 PowerPoint 程序到空白页 (3) 右键单击该空白文档并点击粘贴(您可能有一个额外的空白页在顶部,只需右键单击并剪切以摆脱它)(4)文件/另存为/(选择)PDF 重复每张幻灯片的步骤