Skip to main content
Participant
Mar 27, 2023 9:03 AM UTC
Answered

VBA ReplacePages Method Fails

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 is closed to new replies. Start a new post to keep the conversation going.
Test Screen NameCorrect answer
Legend
Mar 27, 2023 10:19 AM UTC

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. 

3 replies

Test Screen NameCorrect answer
Legend
Mar 27, 2023 10:19 AM UTC

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. 

Translate
Participant
Mar 27, 2023 11:16 AM UTC

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

Regards.

Translate
Participant
Aug 5, 2024 5:13 PM UTC

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.

 

Translate