Forum

Using VBA to read P...
 
Notifications
Clear all

Using VBA to read PDF / Word Doc Content

4 Posts
2 Users
0 Reactions
716 Views
(@gray6)
Posts: 2
New Member
Topic starter
 

Hello all,

I’ve been recently trying to learn how to get VBA to read contents of files for me. I successfully have gotten how to read a text file, but am unable to continue that to PDF or word documents. This is because when I define apps as CAcroApp or CAcroAVDoc, the code does not recognize it though I have the reference tab checked off for the Adobe library. Has anyone got experience using VBA to read pdf’s for them and return the cost of a certain part for example? Or any form of value from a pdf doc? Thank you

 
Posted : 29/05/2022 9:56 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi Gray,

If you want to define objects as CAcroApp or CAcroAVDoc, you need a reference to the Acrobat library. If you don't have a reference to that lib, you have to create the object in late binding:

set obj=CreateObject("CAcroApp")

Word documents and pdf documents can vary a lot, it's hard to build something reliable that works with all possible variations.

Try extracting data with Power Query from pdf files.

 
Posted : 30/05/2022 9:23 am
(@gray6)
Posts: 2
New Member
Topic starter
 

Hello all,

I’ve been recently trying to learn how to get VBA to read contents of files for me. I successfully have gotten how to read a text file, but am unable to continue that to PDF or word documents. This is because when I define apps as CAcroApp or CAcroAVDoc, the code does not recognize it though I have the reference tab checked off for the Adobe library. Has anyone got experience using VBA to read pdf’s for them and return the cost of a certain part for example? Or any form of value from a pdf doc? Thank you

 

I got this,...

 
Posted : 21/06/2022 10:03 am
(@catalinb)
Posts: 1937
Member Admin
 

Nothing attached, we cannot see what you got.

How do you "define apps"?

 Dim AcrobatApplication As New Acrobat.CAcroApp
 Dim AcrobatDocument As New Acrobat.CAcroAVDoc

The declarations above are using EARLY binding and need a reference to Adobe library (Adobe ACROBAT library)
The ones below are using LATE binding, they don't need a reference to the library, but the library must exist:
 Dim AcrobatApplication As Object
 Dim AcrobatDocument As Object

 Set AcrobatApplication = CreateObject("AcroExch.App")
 Set AcrobatDocument = CreateObject("AcroExch.AVDoc")

Adobe ACROBAT must be installed, does not work with Adobe Reader.

Try macropod's sample codes:

http://www.eileenslounge.com/viewtopic.php?p=46636&sid=2456d982c65c8a62be46460469ac068c#p46636

 
Posted : 21/06/2022 2:12 pm
Share: