Hallo,
ich versuche mit Excel VBA den gesamten Text eines PDFs in eine
String Variable zu schreiben. Ich habe "Adobe Acrobat X Pro" aber
die Datei soll später auf Computern benutzt werden, auf denen nur
"Adobe Reader X" (10.1.8) installiert ist.
Auf meinem Computer funktioniert folgende Funktion:
Public Function ReadAcrobatDocument(strFileName As String)
As String
'Note: A Reference to the Adobe Library must be set in
Tools|References!
Dim AcroApp As CAcroApp, AcroAVDoc As CAcroAVDoc,
AcroPDDoc As CAcroPDDoc
Dim AcroHiliteList As CAcroHiliteList, AcroTextSelect As
CAcroPDTextSelect
Dim PageNumber, PageContent, Content, i, j
Set AcroApp = CreateObject("AcroExch.App")
Set AcroAVDoc = CreateObject("AcroExch.AVDoc")
If AcroAVDoc.Open(strFileName, vbNull) <> True Then Exit Function
While AcroAVDoc Is Nothing
Set AcroAVDoc = AcroApp.GetActiveDoc
Wend
Set AcroPDDoc = AcroAVDoc.GetPDDoc
For i = 0 To AcroPDDoc.GetNumPages - 1
Set PageNumber = AcroPDDoc.AcquirePage(i)
Set PageContent = CreateObject("AcroExch.HiliteList")
If PageContent.Add(0, 9000) <> True Then Exit Function
Set AcroTextSelect = PageNumber.CreatePageHilite(PageContent)
On Error Resume Next
For j = 0 To AcroTextSelect.GetNumText - 1
Content = Content & AcroTextSelect.GetText(j)
Next j
Next i
ReadAcrobatDocument = Content
AcroAVDoc.Close True
AcroApp.Exit
Set AcroAVDoc = Nothing: Set AcroApp = Nothing
End Function
Die Funktion rufe ich mit folgender Zeile auf:
myString = ReadAcrobatDocument(myPDF)
Alles funktioniert super, der Text ist in der String Variable und ich
kann damit weiterarbeiten. Aber es läuft nicht auf anderen
Computern, die nur Adobe Reader X installiert haben. Die
Referenzen habe ich angeklickt.
Ich erhalte folgende Fehlermeldung bei
Set AcroApp =
CreateObject("AcroExch.App")
und verstehe nicht wieso:
ActiveX component can't create object.
Könnt ihr mir hier irgendwie weiterhelfen?
Danke und beste Grüße,
critchm!!