Skip to main content
Participant
March 27, 2023
Answered

VBA ReplacePages Method Fails

  • March 27, 2023
  • 1 reply
  • 720 views

I have a macro that opens 2 pdf's and replaces pages from one with the pages from the other.But impossible to obtain a good result. The first PDF don't have the replaced page after save.

 

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

I don't understand why the ReplacePage commande no longer works...

This topic has been closed for replies.
Correct answer Test Screen Name

1. You say it no longer works. When did ir work, and what changed?

2. Do you see the files open and close, or was it invisible anyway?

3. Does the update date change in the "saved" file?

4. Do you check the files open correctly? 
5. Please show the open and save code. 

1 reply

Test Screen NameCorrect answer
Legend
March 27, 2023

1. You say it no longer works. When did ir work, and what changed?

2. Do you see the files open and close, or was it invisible anyway?

3. Does the update date change in the "saved" file?

4. Do you check the files open correctly? 
5. Please show the open and save code. 

Participant
March 27, 2023

Hi Test Screen, 4 was the wrong way. I forgot to put ".pdf" extendsion on Doc2... So now it works perfectly.

Regards.

Participant
August 5, 2024

Can you share your code?  Mine worked perfectly and in the past 6 months it stopped.  I am wondering if it's a security issue with the replace pages command not being set correctly.