PDA

View Full Version : PP slides exported to PDF



Dumbledorf
12-15-2020, 09:19 AM
Hi,

need a bit help with code. I have found it from various places, and made some changes on it.

So, it's working well at the moment, but I have a problem with printing range. I would like to add another print range there, fe. Set PR = .Ranges.Add(Start:=2, End:=2), so it would also print slide 2. But at the moment it only prints last page.

any help with this one, thanks!


Sub PDF()
'This function saves the last slide as a PDF file with a time stamp and the users name who completed the induction.

timestamp = Now()

Dim PR As PrintRange
Dim lngLast As Long
Dim lngFirst As Long
Dim savePath As String
Dim PrintPDF As Integer
Dim name As String

name = ActivePresentation.Slides(2).Shapes("TextBox1").OLEFormat.object.Text


'Location of saved file
savePath = "C:\Powerpoint" & Format(timestamp, "yyyymmdd-hhnn") & " - " & name & ".pdf"

lngLast = ActivePresentation.Slides.Count

With ActivePresentation.PrintOptions
.Ranges.ClearAll ' always do this

Set PR = .Ranges.Add(Start:=lngLast, End:=lngLast)

End With
ActivePresentation.ExportAsFixedFormat _
Path:=savePath, _
FixedFormatType:=ppFixedFormatTypePDF, _
PrintRange:=PR, _
Intent:=ppFixedFormatIntentScreen, _
FrameSlides:=msoTrue, _
RangeType:=ppPrintSlideRange

End sub