title: Export an Array of specific slides in powerpoint to a PDF
body: <p>I made a virtual lab in powerpoint for highschool students, once in a while there is a slide where they are asked a question. They can leave their answer in a Textbox. </p>
  
  <p>At the end i want to insert a button that contains a macro which will save only the slides on which there was a question to a PDF file. The other slides are irrelevant for the teacher.</p>
  
  <p>In short: I am trying to make a PowerPoint macro where I can save a selection of slides as a PDF. Its not a range of slides, but a selection of slides. </p>
  
  <p>Currently i have this:</p>
  
  <pre><code>Private Sub CommandButton2_Click()
  
  Dim mySlides As Variant
  Dim PR As PrintRange
  Dim savePath As String
  Dim myInput As String
  
  'Add the name of the student in the file name
  myInput = ActivePresentation.Slides(1).Shapes("TextBox2").OLEFormat.Object.Text
  
  'Location of saved file
  savePath = ActivePresentation.Path &amp; "\" &amp; myInput &amp; " Antwoorden Virtueel Lab" &amp; ".pdf"
  
  If ActivePresentation.Slides(9).Shapes("TextBox1").OLEFormat.Object.Text = "PRARDT" Then
  
  mySlides = Array(9, 11, 15)
  
  Set PR = ActivePresentation.Slides.Range(mySlides)
  
  
  ActivePresentation.ExportAsFixedFormat _
  Path:=savePath, _
  FixedFormatType:=ppFixedFormatTypePDF, _
  PrintRange:=PR, _
  Intent:=ppFixedFormatIntentScreen, _
  FrameSlides:=msoTrue, _
  RangeType:=ppPrintSlideRange
  
  Else: MsgBox "Does not work"
  
  End If
  
  End Sub
  </code></pre>
  
  <p>However its not working </p>
  
  <p>If I want to do it with a range of slides than i can use this code (Which does work):</p>
  
  <pre><code>Private Sub CommandButton3_Click()
  'This function saves the last slide as a PDF file with a time stamp and the users name who completed the induction.
  Dim PR As PrintRange
  Dim savePath As String
  Dim myInput As String
  
  myInput = ActivePresentation.Slides(1).Shapes("TextBox2").OLEFormat.Object.Text
  
  'Location of saved file
  savePath = ActivePresentation.Path &amp; "\" &amp; myInput &amp; " Antwoorden Virtueel Lab" &amp; ".pdf"
  
  If ActivePresentation.Slides(9).Shapes("TextBox1").OLEFormat.Object.Text = "PRARDT" Then
      With ActivePresentation.PrintOptions
      .Ranges.ClearAll ' always do this
      Set PR = .Ranges.Add(9, 21)
      End With
  
  ActivePresentation.ExportAsFixedFormat _
  Path:=savePath, _
  FixedFormatType:=ppFixedFormatTypePDF, _
  PrintRange:=PR, _
  Intent:=ppFixedFormatIntentScreen, _
  FrameSlides:=msoTrue, _
  RangeType:=ppPrintSlideRange
  
  Else
  MsgBox "something went wrong"
  
  End If
  
  
  End Sub
  </code></pre>
  
  <p>This macro does work, but i can only print a range of slides with it or 1 specific slide. I want to print an Array of specific slides to PDF. I have looked at related questions on this topic however i am such a big noob that i can't fix my problem even with their closely related examples. </p>