+ Reply to Thread
Results 1 to 19 of 19

Excel VBA Adobe Acrobat Javascript AcroExch question.

  1. #1
    Registered User
    Join Date
    10-25-2012
    Location
    Washington DC
    MS-Off Ver
    For MS 365
    Posts
    54

    Excel VBA Adobe Acrobat Javascript AcroExch question.

    The code below seeks to assemble an array of PDFs using the insertpages method of javascript. It works fine if I code it in a way that inserts each document one at a time; however, I am trying to set up the sub so it will take an array of PDF file names and do the same thing.

    When I run the code below I get an error stating "Object variable or With block variable not set" on the line noted below. Since there are no With blocks being used I assume there is a problem with the manner in which I have defined the Document() variable, but I believe it must be "set" as a CAcroPDDoc.

    Any ideas?

    Thanks!

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    One thing that you need is to use Redim Preserve

    Then I would check exactly what is in the array Document.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    10-25-2012
    Location
    Washington DC
    MS-Off Ver
    For MS 365
    Posts
    54

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    Thanks. Would you mind suggesting what that code would look like and where exactly I would put it?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Where you have ReDim replace it with ReDim Preserve.

  5. #5
    Registered User
    Join Date
    10-25-2012
    Location
    Washington DC
    MS-Off Ver
    For MS 365
    Posts
    54

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    Thanks, but it didn't like that. Now I get a "Varibiable not defined" error.

  6. #6
    Registered User
    Join Date
    10-25-2012
    Location
    Washington DC
    MS-Off Ver
    For MS 365
    Posts
    54

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    I realized the "open" method in the AcroExch interface is a boolean function, so I changed it up a bit. It seems to be opneing the PDDoc objects correctly, but I still get the same error as first posted.

    I did verify that the DocsToAssemble array is populated correctly, as is the numPages array.

    Thanks.


    Please Login or Register  to view this content.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    How exactly did you add ReDim Preserve?

    What part of the code errored when you made the change?

  8. #8
    Registered User
    Join Date
    10-25-2012
    Location
    Washington DC
    MS-Off Ver
    For MS 365
    Posts
    54

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    Exact same error as before. "Object variable or With block variable not set" on this line of code:

    "If Document(0).InsertPages(numPages(0) - 1, Document(i + 1), 0, numPages(i + 1), True) = False Then"

    Incidentally, I verified that the Document() array is populating, as is the numPages array.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    I thought it was a variable not defined error after you added Redim Preserve?

  10. #10
    Registered User
    Join Date
    10-25-2012
    Location
    Washington DC
    MS-Off Ver
    For MS 365
    Posts
    54

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    You are correct. And if I add "Preserve" back in there it throws that error on the Redim Preserve line.

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    Just been having a think about this and this is kind of how I would have expected the code to look.
    Please Login or Register  to view this content.
    That probably isn't right, there might not be a Documemts collection of AcroApp.

  12. #12
    Registered User
    Join Date
    10-25-2012
    Location
    Washington DC
    MS-Off Ver
    For MS 365
    Posts
    54

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    Unfortunately, no.

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    Your original code didn't use the instance of the AcroExch application you created.

    Why not?

    Isn't that where the documents should be opened?

  14. #14
    Registered User
    Join Date
    10-25-2012
    Location
    Washington DC
    MS-Off Ver
    For MS 365
    Posts
    54

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    I'm not sure I follow.

    As I understand it, the "Dim AcroApp As Acrobat.CAcroApp" and "Set AcroApp = CreateObject("AcroExch.App")" statements do exactly that, they initialize the Acrobat application. Otherwise I could not create the PDDoc document objects.

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    Yes they initialize the document but you don't refer to it later in the code.

    Anyway, I've had a quick gander at a few things and it seems you don't need to.

    What exactly do you see when you look at Documents in the Watch Window?

    Is it an array of PDDocs?

  16. #16
    Registered User
    Join Date
    10-25-2012
    Location
    Washington DC
    MS-Off Ver
    For MS 365
    Posts
    54

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    I believe I figured it out. I changed the top of the code to look as below and it works. I am defining the arrays as having a depth of "10", but isn't there a way to define them as varying inistead of with a constant?

    Thank you for your help. Your comments helped me look at this from a different angle.


    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    10-25-2012
    Location
    Washington DC
    MS-Off Ver
    For MS 365
    Posts
    54

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    And I asked that last question too soon. Sorry about that as I asnwered it myself.

    Changed the "Dim" to "ReDim" and all is well.

    Please Login or Register  to view this content.

  18. #18
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    Try this.
    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    10-25-2012
    Location
    Washington DC
    MS-Off Ver
    For MS 365
    Posts
    54

    Re: Excel VBA Adobe Acrobat Javascript AcroExch question.

    This is a very nice solution. Much more elegant and efficient than mine. And I think it's a bit faster as well.

    I really appreciate your help.

    Cheers.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1