将特定的PowerPoint幻灯片导出为单个高质量的PDF。

huangapple go评论77阅读模式
英文:

Export specific PowerPoint slides to a single high-quality PDF

问题

我有一个演示文稿,我想要将特定幻灯片打印成单个PDF文件。手动使用“Microsoft打印为PDF”可以得到完美的结果。

但是,演示文稿大约包含72张幻灯片(36对),我想要定期打印它们。演示文稿包含每个样本的2张图纸,我想要创建一个包含这两张图纸的每个样本类型的文档。手动操作这样做非常重复、繁琐,而且容易出错。

当我尝试使用VBA代码进行打印时,使用以下代码:

ActivePresentation.ExportAsFixedFormat

结果质量明显较差,非常模糊。

手动打印2张图纸会生成大约1200 KB的PDF文件,而相同2张图纸的VBA导出只有300 KB。

我正在使用类似以下代码的代码:

Sub ExportSlideDuoToIndividualPDF()
    Dim sPath As String, xPath As String, myletters As String
    Dim steps As Integer, j As Integer, i As Integer

    ' 演示文稿包含每个样本类型的2张图纸
    ' 每个样本类型要打印成一个PDF文档,包含这两张图纸
    ' 样本类型用单个数字表示

    myletters = "ABC" '在代码测试期间只有3个

    sPath = "C:\Output\Drawings for sample @.pdf"

    steps = Len(myletters)
    j = 1 '用于元组的计数器
    For i = 1 To steps
        xPath = Replace(sPath, "@", Mid(myletters, i, 1))
        ActivePresentation.Slides.Range(Array(j, j + 1)).Select
        ActivePresentation.ExportAsFixedFormat Path:=xPath, FixedFormatType:=ppFixedFormatTypePDF, RangeType:=ppPrintSelection
        j = j + 2 '跳到下一个元组
    Next i
End Sub
英文:

I have a presentation of which I want to print specific slides to a single pdf file. Manually printing using "Microsoft print to PDF" gives perfect result.

The presentation however consists of about 72 sheets (36 pairs) I want to print regularly. Presentation contains set of 2 sheets of drawings per sample I want to create a document per sample type containing both sheets. Doing this manually is super repetitive, tedious and I am bound to make mistakes.

When I try to print using VBA code using

ActivePresentation.ExportAsFixedFormat 

the result is significantly of poorer quality, very blurry.

Manually printing 2 sheets gives a pdf file of about 1200 kb and the vba of the same 2 sheets Export is just 300 kb.

将特定的PowerPoint幻灯片导出为单个高质量的PDF。

将特定的PowerPoint幻灯片导出为单个高质量的PDF。

I'm using code that goes somewhat like this:

    Sub ExportSlideDuoToIndividualPDF()
    Dim sPath As String, xPath As String, myletters As String
    Dim steps As Integer, j As Integer, i As Integer

    ' Presentation contains set of 2 sheets of drawings per sample type
    ' A pdf document per sample type to be printed containing the sheets
    ' Sample types are depicted with single digit

    myletters = "ABC" 'Just 3 during code testing

    sPath = "C:\Output\Drawings for sample @.pdf"

    steps = Len(myletters)
    j = 1 'Of set counter for tupple
    For i = 1 To steps
        xPath = Replace(sPath, "@", Mid(myletters, i, 1))
        ActivePresentation.Slides.Range(Array(j, j + 1)).Select
        ActivePresentation.ExportAsFixedFormat Path:=xPath, FixedFormatType:=ppFixedFormatTypePDF, RangeType:=ppPrintSelection
        j = j + 2 ' jump to next tupple
    Next i


    End Sub

答案1

得分: 1

请阅读以下文档:
https://learn.microsoft.com/en-us/office/vba/api/powerpoint.presentation.exportasfixedformat#example

并根据需要将屏幕(低质量)更改为打印(您的需求)进行调整:

Public Sub ExportAsFixedFormat_Example()
    ActivePresentation.ExportAsFixedFormat "C:\Output\Drawings for sample @.pdf", ppFixedFormatTypePDF, ppFixedFormatIntentPrint, , , ppPrintOutputBuildSlides, , ppPrintSlideRange, , , , , ,
End Sub

因此,使用您的循环方法将意图设置为打印:

ActivePresentation.ExportAsFixedFormat Path:=xPath, FixedFormatType:=ppFixedFormatTypePDF, ..., Intent:=ppFixedFormatIntentPrint
英文:

Read the doc
https://learn.microsoft.com/en-us/office/vba/api/powerpoint.presentation.exportasfixedformat#example

and adjust so here changed screen (low quality) to print (your desire)

Public Sub ExportAsFixedFormat_Example() 
 
       ActivePresentation.ExportAsFixedFormat "C:\Output\Drawings for sample @.pdf", ppFixedFormatTypePDF, ppFixedFormatIntentPrint, , , ppPrintOutputBuildSlides, , ppPrintSlideRange, , , , , ,  
 
End Sub

Thus using your in loop ? method set intent to Print

    ActivePresentation.ExportAsFixedFormat Path:=xPath, FixedFormatType:=ppFixedFormatTypePDF, ..., Intent:=ppFixedFormatIntentPrint

答案2

得分: 0

默认的Intent:=ppFixedFormatIntentSreen证明是个问题。添加Intent:=ppFixedFormatIntentPrint解决了这个问题!

英文:

the default Intent:=ppFixedFormatIntentSreen proves to be the problem. Adding Intent:=ppFixedFormatIntentPrint solved the problem!

答案3

得分: -1

你试过我能找到的这些方法吗?

附注:只要我得到你的回应,我可能仍然能够在这里添加我的答案。这只是一个指南,不会结束在这里。如果你能按照我的指南去做,就不需要我的帮助了,那为什么我要重复它们呢?如果你确实能够独立完成,那当然是最好的,我也不需要越权。你同意吗?

英文:

Did you try these methods I could figure out?

> ps. As long as I get your response, I may still be able to add my answer here. It's just a guideline, it doesn't end here. If you can follow my guidelines and do it, doesn't need my help anymore, so why should I repeat them? If you can actually make it on your own, of course, the best, and I do not need to exceed the authority of it. Would you agree?

huangapple
  • 本文由 发表于 2023年6月2日 03:22:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76385071.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定