Link to home
Start Free TrialLog in
Avatar of Simon Boutin
Simon Boutin

asked on

Export .PDF to Excel using VBA

Hi,
I must export a batch of .PDF files to Excel by matching as close as possible the original .PDF files (not just text transfert).
I have a subscription with Adobe Acrobat Pro but I can't find any examples of source code to help me with this challenge.
I'm already an expert with VBA through MS Access, but I'm very beginner at using Adobe Acrobat functions, objects and so on.
I really need examples written in VBA that can do that.
Thanks!
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

It would helpful to share a sample of how "much" migration you want to perform ....transferring Content from PDF to other format is a rather BIG questionmark...just about everybody claim that they do but there always cases that the fail...
I'm with John... a little more idea of what you are trying to do would help.
When you mention "a batch of .PDF files" it conjures up visions of Access reports being exported to .PDF (Otherwise, why export to a document format like .PDF in the first place?)  Or, are the .PDFs already existing as separate files and you just want to use Access VBA to put the content of the files into Excel, with the data blocks in the .PDF existing in Excel like a table?
What do you want the export to look like when it finally gets to Excel?  A .PDF inserted into Excel?  A block of data (or several blocks of data) inserted into Excel?
I've been in this business for over 25 years and I've NEVER had a occasion to do something like this.  Please explain a little better, please...
Avatar of Simon Boutin
Simon Boutin

ASKER

I generate maybe 30 to 50 .pdf files per day like this one in attachment.
They are MS Access reports which I save as .pdf files.
Now I need to convert all those .pdf files into Excel files for the end users be able to manipulate data inside and maybe create a MS Access procedures able to read back those Excel files for other needs.
Once save as Excel, I want that the look are as close as possible of the original .pdf files.
If I have rectangles that surround texts, I want to keep these rectangles (as cells' border) in the final Excel files.
I can already do that manually with Adoba Acrobat Pro.
Now I want to automatise the entire process using VBA for 30 to 50 .pdf files in one shot.
Please tell me if you need more info.
Thanks!
What is the source of PDFs ...if they originate from Access data then the  logical solution is to export them to Excel directly ...
I' have no idea how you would "read" the formatting like borders and boxes in a .PDF file so you can "copy" (add) the same formatting in Excel.

Exporting blocks of data (recordsets/queries/tables) directly to Excel using Access's Transferspreadsheet() function, or Excel's CopyFromRecordset() function using Excel VBA in an Access module, and then using Excel VBA in Access module to put formatting (or anything else available in Excel) into your Excel file is done all the time.  You could even create Excel templates that you copy and export data into.

There is a great abundance of google-searchable help on how to do this if you know the right search words to use:
Access vba Transferspreadsheet function.
Excel vba CopyFromRecordset function.
Using Excel vba in Microsoft Access vba.
Exporting data from Microsoft Access to Excel.
etc., etc., etc....

One thing you'll want to do is convert any Excel early binding code (reference to Excel application required and all users have the version referenced, or they learn how to change the reference to the version they have on their machine if a binding error occurs) to late binding code (no reference to Excel application required -prevents errors caused by the user having a different version of Excel).

I'm sure there are many experts out there with lots of experience in this area who have the time to walk you through this.  It's been my experience that it takes awhile to train a newbie in how to code excel vba for use in Access.  It would help if we knew how comfortable you feel about using Excel vba in Access.  

Just a note:  Being able to create, open, modify, and export Excel files with Access vba code opens up a whole new world for folks who have tried to use Excel to do database work.  Many developers use Access to do the data processing while using Excel as just a data source and/or as a export/reporting medium.  Eliminates the need for a bunch of processing formulas, formats, and Excel vba code in workbooks.  Once you've seen what you can do with Excel running Excel vba in Access, you'll never go back to "Excel Hell" again!  :-)  Just thinking out loud...
They are MS Access reports which I save as .pdf files.
Now I need to convert all those .pdf files into Excel files
There were no pdf's attached so we can't see what you want the export to look like but it makes no sense at all to export a report to pdf and then try to parse the pdf and recreate it in Excel.  As Mark suggested, just go straight to Excel.  Once we have some ideal of what you are looking for, we can propose sample code to get you started.
Thank you both for your responses,
my boss just found how to convert a batch of .pdf files into Excel (manually) using "adobedocumentcloud ".
Here is the video link:

       https://recordings.join.me/K3x-xalM1kq843_YgqnreQ

I'm already familiar with the possibilities of Access and Excel (maybe not as much as you).

My boss also find this very interresting link but I didn't tried it yet:

       https://stackoverflow.com/questions/33525366/convert-multiple-pdf-to-excel-unable-to-initiate-app

I think this piece of code is what I'm searching for.
Now I will try it to work as intended.
To be continued...
ASKER CERTIFIED SOLUTION
Avatar of Simon Boutin
Simon Boutin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You do realize I hope that using code that automates Adobe means that EVERY user of your application who needs to perform this function must have a full Adobe license????    That is only one of the reasons we recommended against this course of action.
Since the Boss found the solution everything else is just trivial.... :)