Skip to main content
Participating Frequently
December 2, 2021
Question

VBA Code Split a PDF file according to the specified file size of 16 MB

  • December 2, 2021
  • 5 replies
  • 6074 views

In VBA (Excel) I found a way to save one PDF files in individual PDF files (only 1 Side per File) using Adobe Acrobat DC. Unfortunately I can't find any VBA code to split a PDF file into multiple PDF files of the same size. This option is available in Adobe DC. Can you provide me with a VBA code as an example?

Thanks

Dietmar

This topic has been closed for replies.

5 replies

JR Boulay
Community Expert
Community Expert
December 8, 2021

I don't know anything about VBA, that's why I was asking this question.

Acrobate du PDF, InDesigner et Photoshopographe
Participating Frequently
December 10, 2021

Unfortunately, no solution has yet been found, shouldn't this requirement be made quite often?
The Adobe element is defined in vba and can then be accessed on Adobe like this.

Set PDDoc = CreateObject("AcroExch.pdDoc")

You need this Reference Adobe Acrobat 10.0 Object Library e.g. in Excel:

then you can use the acrobat commands

It would be nice if there is a VBA specialist at Adobe who has some programming experience who could solve the small requirement.

Nice Weekend

Regards

Dietmar

 

 

 

Legend
December 10, 2021

The Acrobat API is about 20 years old and has not been updated. But this feature is much less than 20 years. Trial and error, which you seem to reject, is in fact your way forward. Yes, of course, each page can be a wildly different size. This is why you need to try many possible solutions and pick the best.

JR Boulay
Community Expert
Community Expert
December 7, 2021

Can you operate Acrobat with VBA?

 

Acrobate du PDF, InDesigner et Photoshopographe
Participating Frequently
December 7, 2021

Thank you, but that's the easy way to use the menu in the program. I'm looking for a Code to do that with Visual basic (VBA). Currently I can only create a new file after PDF pages in VBA Excel. 

My problem is that I have 100,000 PDF files in different file sizes. Whenever the PDF file size is larger than 16MB, the VBA routine should split the PDF file into a maximum of 16MB.
If I do this by hand, then it will take me far too much time. This should be done by machine in 10 minutes.
The prerequisite is of course that Adobe DC is installed.

Do you know anyone who is using VBA for a solution.

 

Bernd Alheit
Community Expert
Community Expert
December 7, 2021

You can use a trial and error approach. Extract some pages and check the file size. And so on.

Participating Frequently
December 7, 2021

Unfortunately, this is not a solution, as some PDF files with two pages with high-resolution images can already have 16 MB and there are also PDF files with 250 pages that are only 5 MB in size. So this solution cannot work.
Do you know a solution with Visual Basic for Applications (VBA) ?

Bernd Alheit
Community Expert
Community Expert
December 7, 2021

This solution will work.

Bernd Alheit
Community Expert
Community Expert
December 6, 2021

Want you the exact file size for all files?

Participant
December 6, 2021

not necessairly

Participant
December 6, 2021

Hi, i need this example too 😉