UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Searching Pdf With Access 2010, Access 2010    
 
   
Pastor Del
post Aug 13 2017, 08:49 PM
Post#1



Posts: 329
Joined: 27-July 10



i'm trying to search for text & page number in a PDF with VBA in Access 2010. I am opening the PDF with Adobe Acrobat Reader DC. i found the following code but i get error 429 "ActiveX component can't create object" on both Set objApp = CreateObject("AcroExch.App") & Set objPDDoc = CreateObject("AcroExch.PDDoc"). Can anyone help me figure this out?

***** Added details: I'm looking for code that will find a particular string in a PDF & return the page number(s) where the string is found *****

References:
Visual Basic for Applications
MS Access 14.0 Object Library
OLE Automation
MS Office 14.0 Access database engine Object Library
Acrobat Access 3.0 Type Library
Adobe Acrobat Browser Control Type Library 1.0
Acrobat Reader File Preview Type Library

CODE
[/code]Sub test_with_PDF()
'   Original code found at:
'   http://social.msdn.microsoft.com/Forums/en-US/2c2bb856-d8d9-4624-80a1-2425a5660e8c/how-to-use-VBA-to-view-pdf-file-and-use-an-ocr-object
'   The original subroutine concatenated all of the found text and displayed it.
'   This modification searches each word in a PDF for a specific string, and lets
'   you know each time the word is encountered.
    Dim objApp As Object
    Dim objPDDoc As Object
    Dim objjso As Object
    Dim wordsCount As Long
    Dim page As Long
    Dim i As Long
    Dim strData As String
    Dim strFileName As String
    
    strFileName = "H:\Corporate Phone Book.pdf"
    
    Set objApp = CreateObject("AcroExch.App")
    Set objPDDoc = CreateObject("AcroExch.PDDoc")
    'AD.1 open file, if =false file is damage
    If objPDDoc.Open(strFileName) Then
        Set objjso = objPDDoc.GetJSObject
        For page = 0 To objPDDoc.GetNumPages - 1
            wordsCount = objjso.GetPageNumWords(page)
            For i = 0 To wordsCount
                'AD.2 Set text to variable strData
                If objjso.getPageNthWord(page, i) = "DENNIS" Then
                    MsgBox "I found a Dennis on page " & page
                End If
            Next i
        Next
        MsgBox "Done"
    Else
        MsgBox "error!"
    End If
End Sub[code]
Go to the top of the page
 
theDBguy
post Aug 13 2017, 10:16 PM
Post#2


Access Wiki and Forums Moderator
Posts: 71,230
Joined: 19-June 07
From: SunnySandyEggo


Hi,

You may need the full version of Adobe Acrobat. Perhaps Acrobat Reader cannot create an Acrobat object.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
moke123
post Aug 14 2017, 12:20 AM
Post#3



Posts: 1,148
Joined: 26-December 12
From: Western Ma.,L.I.,N.Y.,Jupiter,Fl.



theres an old post from Doctor9 which can be found here...read a pdf
I was able to adapt it read thru the pdf and import it line by line into a table where it could be further processed.
in essence it reads a pdf character by character and determines the end of a line by a carriage return.

the caveat however is you need a FULL version of Adobe Acrobat

Some of the other options I experimented with was converting the pdf to excel and linking to that excel file and converting to a word document and reading that into a table.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    15th December 2017 - 10:19 PM