tags:

views:

543

answers:

2

Using MS Access, I need to open a PDF file, move the last page of the file to the first, and save it. But the error (see below) keeps getting in my way. (I'm good with VBA, but this is my first attempt at manipulating PDF with VBA).

Note: I'm using AcroRd32.DLL

Option Compare Database
Option Explicit

    Sub x()
        Dim PDFdoc As New AcroPDDoc
        PDFdoc.Open "C:\Reports\MRIR\mrir.pdf" 'activex comp. can't create object
        PDFdoc.MovePage 0, PDFdoc.GetNumPages
        PDFdoc.Save 1, "C:\reports\MRIR\Switched.pdf"
    End Sub
+1  A: 

If you just call the document with a shell method, then the following will work according to the following Adobe help file:

http://www.adobe.com/devnet/acrobat/pdfs/PDFOpenParameters.pdf

When opening a PDF document from a command shell, you can pass the parameters to the open command using the /A switch using the following syntax:

<path to Acrobat> /A "<open parameter>=OpenActions" "<path to PDF file>"

For example:

Acrobat.exe /A "page=4=OpenActions" "C:\example.pdf"
David Walker
A: 

Thanks all, but since I don't have Adobe Acrobat on my local machine (just the reader), I found a 3rd party freeware program (PDFTK) that can do this kind of basic page manipulation from the command-line.

(Kudos to David Walker for giving a detailed answer, even though I couldn't use it in the end.)

PowerUser