After the comment exchange in the answer by Steve Rindsberg, I concluded the way to go is with VBA (which I meant to avoid).
I am posting here the code I used.
At the point of having written the code, it gives flexibility for adding features, e.g., do not export hidden slides.
I added concatenation of images into a single PDF file (this can also be done with Adobe Acrobat, ImageMagick's convert, etc.)
Note that ExportAsFixedFormat
requires ppFixedFormatIntentPrint
, otherwise output quality is lost again.
Hope this is useful for others.
Sub ppt2images(Optional path As String = "")
'
' If not given, use for the output directory the same as in the original presentation
'
On Error GoTo Err_ImageSave
' Set paths and file names
Dim oPres As Presentation
Set oPres = ActivePresentation
Dim sImagePath As String
Dim sPrefix As String
sPrefix = Split(oPres.Name, ".")(0)
If (path = "") Then
path = oPres.path
End If
sImagePath = path & "\" & sPrefix
If Dir(sImagePath, vbDirectory) <> vbNullString Then
'MsgBox "Folder " & sImagePath & " exist"
Else
MkDir (sImagePath)
End If
' Get current resolution
Dim ps As PageSetup
Set ps = oPres.PageSetup
Dim lScaleWidth As Long '* Scale Width
Dim lScaleHeight As Long '* Scale Height
lScaleWidth = ps.SlideWidth
lScaleHeight = ps.SlideHeight
Dim ar As Double
ar = lScaleWidth / lScaleHeight
' Set target resolution
Dim newWidth As Long '* Scale Width
Dim newHeight As Long '* Scale Height
newWidth = 4096
newHeight = newWidth / ar
' Create new temporary presentation to add generated images as slides
Dim oPresTmp As Presentation
' Create it as not visible
Set oPresTmp = Presentations.Add(msoFalse)
' Copy page size from the source presentation
With oPresTmp.PageSetup
.SlideHeight = oPres.PageSetup.SlideHeight
.SlideWidth = oPres.PageSetup.SlideWidth
End With
Dim oSlideNew As Slide '* Slide Object
Dim oPic As Shape
' Export slides
Dim sImageName As String
Dim oSlide As Slide '* Slide Object
Dim img_format As String
img_format = "png"
For Each oSlide In oPres.Slides
With oSlide
' If slide is not hidden
If (.SlideShowTransition.Hidden = msoFalse) Then
' Export slide
sImageName = sImagePath & "\" & sPrefix & "-" & Format$(.SlideIndex, "000") & "." & img_format
.Export sImageName, img_format, newWidth, newHeight
' Add it to the temporary presentation
Set oSlideNew = oPresTmp.Slides.Add(oPresTmp.Slides.Count + 1, ppLayoutBlank)
Set oPic = oSlideNew.Shapes.AddPicture(FileName:=sImageName, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=0, _
Top:=0, _
Width:=-1, _
Height:=-1)
' width/height of -1 tells PPT to import the image at its "natural" size
End If
End With
Next oSlide
With oPresTmp
' Export temp presentation to pdf
Dim sPDFName As String
sPDFName = sImagePath & ".pdf"
.ExportAsFixedFormat sPDFName, ppFixedFormatTypePDF, ppFixedFormatIntentPrint, msoFalse, _
ppPrintHandoutVerticalFirst, ppPrintOutputSlides, msoFalse
' Close temp presentation
.Saved = True
.Close
End With
Err_ImageSave:
If Err <> 0 Then
MsgBox Err.Description
End If
End Sub