extract pages from pdf

rikvny02

Board Regular
Joined
Aug 9, 2022
Messages
78
Office Version
  1. 365
Platform
  1. Windows
Hello
I already have the file name (column A), page numbers (column B). Is there a way to extract the pages from a PDF (actively open) using vba. I've found several post about extracting certain words but nothing about extracting and saving specific pages. Any help would be appreciated. Thank

1682515361829.png


save as C:/ wages
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
You could do this with the Acrobat API from VBA, however Acrobat Pro must be installed.

Alternatively, a command-line tool such as PDFtk Server, run from VBA, could be used, specifically the cat command. I don't think it can 'attach' to the currently open PDF, so you'd have to specify the full file name of the PDF in the code. The cat commands to create "north.pdf" and "ops.pdf" from specific pages in "input.pdf" would be:

Code:
PDFtk "C:\path\to\input.pdf" cat 10-16 output "C:\path\to\north.pdf"
PDFtk "C:\path\to\input.pdf" cat 32-155 171-178 180-192 output "C:\path\to\ops.pdf"
 
Upvote 0
You could do this with the Acrobat API from VBA, however Acrobat Pro must be installed.

Alternatively, a command-line tool such as PDFtk Server, run from VBA, could be used, specifically the cat command. I don't think it can 'attach' to the currently open PDF, so you'd have to specify the full file name of the PDF in the code. The cat commands to create "north.pdf" and "ops.pdf" from specific pages in "input.pdf" would be:

Code:
PDFtk "C:\path\to\input.pdf" cat 10-16 output "C:\path\to\north.pdf"
PDFtk "C:\path\to\input.pdf" cat 32-155 171-178 180-192 output "C:\path\to\ops.pdf"
I do have pro. Thanks for the jump start
 
Upvote 0

Forum statistics

Threads
1,215,261
Messages
6,123,931
Members
449,134
Latest member
NickWBA

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top