Results 1 to 2 of 2
  1. #1
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862

    VBA Example: Extract and Save pages from PDF. Must have Adobe Acrobat

    I searched the internet for good examples to do this. I did not find any. Most were overly complex and or incorporated other features and functions that clouded the basics of extracting and saving a page from a PDF file. So here is my version.

    Sometimes vendors, clients, or others will provide you with a PDF file that contains many pages. You may want to extract each page and make this single page a new PDF file, one file for each page in the original PDF. The following code will create a new PDF file for the second page in the original source file. This code requires interaction with an Adobe dll and uses early binding. You must make a reference to the Adobe library and in order for the code to be granted access to the DLL, you need to have Adobe Acrobat installed on the computer that runs the code.

    This code will not work if you only have Adobe Reader installed. The reference will be available if reader is installed but the code will only work if Acrobat is installed.




    Code:
    'Extract the second page from
    'a source PDF and create a new
    'PDF file with the single page
    'Must have Adobe Acrobat installed
    'not just Adobe Reader. Reference
    'Adobe Acrobat XX.X Type Library
    'for this Early Binding example
    Dim strPath As String
    Dim pdfDocNew As New Acrobat.AcroPDDoc
    Dim pdfSource As New Acrobat.AcroPDDoc
    strPath = "C:\Test\"
    pdfDocNew.Create
    pdfSource.Open strPath & "Source.pdf"
    pdfDocNew.InsertPages -1, pdfSource, 1, 1, 0
    pdfDocNew.Save Acrobat.PDSaveFull, strPath & "MyNewFile.pdf"
    pdfSource.Close
    pdfDocNew.Close
    Set pdfSource = Nothing
    Set pdfDocNew = Nothing
    MsgBox "Complete"
    Like I mentioned, this is just the basics. Extract a page and save it. You will probably want to include additional functionality in your app. Here is some reference material I found to be helpful.


    http://www.adobe.com/content/dam/Ado..._reference.pdf

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816

    Combine Acrobat PDF documents

    And here is example of the opposite - combining PDFs: https://www.accessforums.net/access/...pdf-25574.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 01-23-2014, 09:36 AM
  2. Acrobat Forms
    By sdc1234 in forum Misc
    Replies: 5
    Last Post: 12-13-2013, 12:57 PM
  3. Replies: 10
    Last Post: 10-07-2013, 08:20 AM
  4. How do you(Acccess to Adobe in VBA)
    By Madmax in forum Access
    Replies: 10
    Last Post: 06-28-2012, 04:18 PM
  5. Blank pages between report pages
    By jonsuns7 in forum Reports
    Replies: 2
    Last Post: 10-01-2009, 05:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums