title: Split PDF into new files per page - Excel VBA
body: <p>I am trying to split a pdf into multiple new files per page.
  I found this code on <a href="https://www.excelforum.com/excel-programming-vba-macros/1157046-split-pdf-file-into-individual-pages-using-vba.html#post5402470" rel="nofollow noreferrer">Excel Forum</a>
  I modified it to to suit my folder path and file.
  I have also added the Acrobat.tdl library to references.(Don't have the actual acrobat pro installed. Followed the steps suggested in this <a href="https://stackoverflow.com/questions/60352098/cant-find-the-adobe-acrobat-10-0-type-library-2020">link</a>)</p>
  <p>However, when I try to run the code, I get the error - Run-time error '429': ActiveX component can't create object.
  The error occurs on the line <code>Set PDDoc = CreateObject(&quot;AcroExch.pdDoc&quot;)</code></p>
  <p>Here is the full code:</p>
  <pre><code>Sub SplitPDF()
    Dim PDDoc As Acrobat.CAcroPDDoc, newPDF As Acrobat.CAcroPDDoc
    Dim PDPage As Acrobat.CAcroPDPage
    Dim thePDF As String, PNum As Long
    Dim f As String, i As Integer, Result As Variant, NewName As String
    
    f = ThisWorkbook.Path &amp; &quot;\&quot;
    thePDF = f &amp; &quot;CDE_9740240D_2020-09-08.pdf&quot;
    
    Set PDDoc = CreateObject(&quot;AcroExch.pdDoc&quot;)
    Result = PDDoc.Open(thePDF)
    If Not Result Then
       MsgBox &quot;Can't open file: &quot; &amp; thePDF
       Exit Sub
    End If
    
    '...
    PNum = PDDoc.GetNumPages
    
    For i = 0 To PNum - 1
      Set newPDF = CreateObject(&quot;AcroExch.pdDoc&quot;)
      newPDF.Create
      NewName = f &amp; &quot; Page_&quot; &amp; i &amp; &quot;_of_&quot; &amp; PNum &amp; &quot;.pdf&quot;
      newPDF.InsertPages -1, PDDoc, i, 1, 0
      newPDF.Save 1, NewName
      newPDF.Close
      Set newPDF = Nothing
    Next i
  End Sub
  </code></pre>
  <p>Can someone please help me make this code work.</p>