PDF file into individual pages using VBA (Visual Basic for Applications) in Microsoft Excel.

 Sub SplitPDFPages()

    ' Declare variables

    Dim AcrobatApp As Object

    Dim AcrobatDoc As Object

    Dim PDFPath As String

    Dim PDFName As String

    Dim SavePath As String

    Dim i As Integer

    

    ' Set the path to the PDF file

    PDFPath = "C:\example\input.pdf"

    ' Set the save path for the individual PDF pages

    SavePath = "C:\example\"

    ' Get the PDF file name

    PDFName = Dir(PDFPath)

    

    ' Create an instance of Adobe Acrobat

    Set AcrobatApp = CreateObject("AcroExch.App")

    ' Open the PDF file

    Set AcrobatDoc = AcrobatApp.GetActiveDoc(PDFPath)

    

    ' Loop through each page in the PDF file and extract it

    For i = 0 To AcrobatDoc.GetNumPages() - 1

        ' Extract the current page

        AcrobatDoc.SaveAs SavePath & "Page " & i + 1 & ".pdf", "com.adobe.acrobat.pdf"

        AcrobatDoc.GoToNextPage

    Next i

    

    ' Close the PDF file and exit Adobe Acrobat

    AcrobatDoc.Close

    AcrobatApp.Exit

End Sub


Comments

Popular posts from this blog

how to work step-down transformer

Python project to exe

Excel formula Sum/Max/Min