• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

VBA ReplacePages Method Fails after new Acrobat Pro Install

New Here ,
Oct 25, 2022 Oct 25, 2022

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!

TOPICS
Acrobat SDK and JavaScript

Views

657

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 25, 2022 Oct 25, 2022

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 26, 2022 Oct 26, 2022

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2023 Aug 28, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 28, 2023 Aug 28, 2023

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. 

   

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2023 Aug 28, 2023

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 29, 2023 Aug 29, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 29, 2023 Aug 29, 2023

Copy link to clipboard

Copied

LATEST

Hi, @Steven267925802wen 

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines