Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
I believe the solution I found was actually in the settings of Adobe Acrobat, specifically in Preferences > Security (Enhanced) and then turning off Protected View, don't enable at startup. Here's an example of working code for replacepages at stackoverflow.
Copy link to clipboard
Copied
Thank you for the advice.
After trying the method you mentioned, the ReplacePages method started functioning properly.
I couldn't find a solution even after searching the website, so I'm truly grateful for your help.