Get Text from an Acrobat PDF file into MS-Access database using IAC or DOM interface

I need to be able to parse a PDF file and get the data into MS-Access. Ideally the user should be able to hilite some text or a table in the PDF, and make entries in an MS-Access form to say what is to be done, then push a button and have it happen. How do I connect the connect the selection in the PDF with an AcroPDTextSelect object in the VBA? The only way seems to be to set the selection from the VBA, but I can't figure out what to put in the AcroRect object to use AcroExch.PDDoc.CreateTextSelect. When I try to build an AcroHiliteList object to use AcroPDPage.CreateWordHilite, it bombs on the .Add method.

The other alternative I have looked at is using the Accessibility (AcrobatAccess.lib) DOM interface, but I haven't found out how to attach the root IPDDomElement to a file.

Here is my test code.

***********Begin code
Option Compare Database
Option Explicit

' Copyright (c) 2006, Lyle Anderson All rights reserved.
Dim appAcrobat As AcroApp
Dim strPDFfilePath As String
Dim pdfForEdit As AcroAVDoc
Dim avpPageForEdit As AcroAVPageView
Dim pddDocumentForEdit As AcroPDDoc
Dim avdDocumentForEdit As AcroAVDoc
Dim pdpPageForEdit As AcroPDPage
Dim pdtTextSelection As AcroPDTextSelect
Dim bolAcrobatForEditRunning As Boolean
Dim lngCurrentPageNum As Long
Dim recCurrentRectangle As AcroRect
Dim objHiliteList As AcroHiliteList
Public Sub readPDFdocument(varPath As Variant)
Dim strPath As String
If IsBlank(varPath) Then
strPath = getPDFfilePath()
Else
strPath = setPDFfilePath(varPath)
End If
If appAcrobat Is Nothing Then
Set appAcrobat = New Acrobat.AcroApp
End If
appAcrobat.Show ' This works fine
If pdfForEdit Is Nothing Then
Set pdfForEdit = New AcroAVDoc
End If
If pdfForEdit.Open(strPath, "Temp Title") Then
Set avpPageForEdit = pdfForEdit.GetAVPageView
avpPageForEdit.GoTo (89) ' Page 90 shows on the screen OK
End If
End Sub

I know how to do this with XML, Excel, Word, and PowerPoint, but it would be really helpful to be able to process PDF files without converting them to Word. As a backup I can use the convert table to Excel feature in Adobe Acrobat, but I really want this to be more integrated than that.

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications. You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.

Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …