좋아, 그래서 몇 달 간의 검색을 거쳐 결국 답을 찾았으니 여기에서 공유하고 싶다고 생각했다. 대부분의 코드는 그물에서 발견되는 무작위적인 부분과 내 자신의 짧은 코드를 통해 제공됩니다.
Sub Generate_PDF_Cert()
'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 savePath As String
Dim PrintPDF As Integer
'Location of saved file
savePath = Environ("USERPROFILE") & "\Desktop\Induction\Certificates\" & Format(timestamp, "yyyymmdd-hhnn") & "_" & FirstNameX & "_" & LastNameX & ".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
'Prompt user of file location and option to print.
PrintPDF = MsgBox("A PDF file of this certificate has been saved to: " & vbCrLf & savePath & vbCrLf & vbCrLf & "Would you like to print a copy also?", vbYesNo, "PDF File Created")
If PrintPDF = 6 Then Call Print_Active_Slide
End Sub
PDF가 멋지고 쉽게 생성되었습니다. 기본적으로 프로그램의 마지막 슬라이드를 가져 와서 해당 슬라이드 만 PDF로 내 보냅니다. 특정 슬라이드 또는 슬라이드 범위로 변경할 수 있습니다. 그런 다음 선택한 슬라이드를 다음 기능으로 인쇄 할 수도 있습니다.
Sub Print_Active_Slide()
' This code determines what slide is currently visible in the
' slide show and then it clears the print range and prints out the
' current slide.
' Declare lSldNum as a long integer.
Dim lSldNum As Long
' Assign lSldNum to the current slide number.
lSldNum = SlideShowWindows(1).View.Slide.SlideNumber
' Set the print options for the active presentation.
With ActivePresentation.PrintOptions
' Set RangeType to print a slide range.
.RangeType = ppPrintSlideRange
' Delete old print range settings.
.Ranges.ClearAll
' Set Ranges to the new range for the current slide.
.Ranges.Add lSldNum, lSldNum
End With
' Using the current print settings print the slide to the default
' printer.
ActivePresentation.PrintOut
MsgBox "The file has been sent to the default printer", vbOKOnly, "Print Job Sent"
End Sub
출처
2017-01-16 15:50:32
MrK