Skip to main content
Participant
Oct 25, 2022 10:55 PM UTC
Question

VBA ReplacePages Method Fails after new Acrobat Pro Install

I have a macro that opens 2 pdf's and replaces pages from one with the pages from the other. It was working before I moved to a new computer. Both computers are running Acrobat Pro -- but the older one was using 2017 version, and the new one is using the newest Acrobat pro subscription license.

 

Is there something that's changed that would make this method now fail?

 

        If Doc1.ReplacePages(Doc1.GetNumPages - 7, Doc2, 0, Doc2.GetNumPages, 1) = False  Then
            MsgBox "Cannot replace pages"
            Exit Sub
        End If

 

My code executes fine - but now returns "FALSE" but previously was working fine.

 

Thanks!

This topic is closed to new replies. Start a new post to keep the conversation going.

7 replies

Participant
Aug 28, 2023 10:37 PM UTC

Hi, @Steven267925802wen 

I am also encountering the same error. After installing the new Acrobat, the ReplacePages method started returning False.

Have there been any developments since then? If there have been any updates, I would greatly appreciate it if you could share the information.

Thank you in advance.

Translate
Thom Parker
Community Expert
Community Expert
Aug 28, 2023 11:29 PM UTC

I would strongly suggest that you put all of your JavaScript code into an Acrobat folder level function. Test it from the Acrobat Console window to make sure it is all working, then call the folder level function from your VBA.

 

The conversion from the VBA context into the JavaScript context is not clean one. This is especially true for non-generic objects such as the Doc object. In fact, the first code posted by steven is problematic for this reason. He does not show the code used to acquire the Doc objects. So we don't know if they are actually JS docs. But even if they are, it is better to call the document functions directly from the JSO.  It may the use of the doc object that was the problem in the first place. But regardless. You are protected from these types of issues by using a folder level function to perform all of the Acrobat JavaScript functionality. 

   

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
Aug 29, 2023 4:56 AM UTC

Thank you for the advice you provided.

I would like to try using the replacePages method with JavaScript from VBA, but I can't find any samples.

Do you know of any samples for calling the method?

Translate
Legend
Oct 26, 2022 3:57 AM UTC

Are you able to do the insertion manually on those exact files (using Organise pages or drag and drop of thumbnails). The first thing is to verify that it isn't a problem with the files.

Translate
Participant
Oct 26, 2022 3:31 PM UTC

Hi, thanks for responding. Yes, I am able to manually do that.

 

Also FYI - I checked the reference libraries in VBA that are enabled & have Adobe 10.0 Type Library enabled, and also added Acrobat Access 3.0 Type Library for good measure. No luck. 

Translate