VBA: How to get high quality export to PDF in Powerpoint with VBA

Watapana 0 Reputation points
2023-05-28T13:43:27.7266667+00:00

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.

Attached detail showing the difference

Manually exported quality.jpg

VBA exported quality.jpg

I'm using code that goes something 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
PowerPoint
PowerPoint
A family of Microsoft presentation graphics products that offer tools for creating presentations and adding graphic effects like multimedia objects and special effects with text.
304 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,735 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,983 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.