首页 > 解决方案 > 从 pdf 中提取特定数据点。出现“类未注册”错误

问题描述

我正在尝试在 pdf 中搜索字符串并在这些字符串之后提取数据点。但是我在这行代码中收到“类未注册”错误。我使用的参考是 Adob​​e Acrobat 8​​.0 Type Library 请帮忙。谢谢

If (objAvDoc.Open(strFilename, "")) Then

上面一行的语法错误

Sub callFunc()

    getTextFromPDF ("C:\XXXXXX\XXXXX\6. CDS vs FA\052835022.pdf")

End Sub


Function getTextFromPDF(ByVal strFilename As String) As String
   Dim objAVDoc As New AcroAVDoc
   Dim objPDDoc As New AcroPDDoc
   Dim objPage As AcroPDPage
   Dim objSelection As AcroPDTextSelect
   Dim objHighlight As AcroHiliteList
   Dim pageNum As Long
   Dim strText As String

   strText = ""
   If (objAvDoc.Open(strFilename, "")) Then
      Set objPDDoc = objAVDoc.GetPDDoc
      For pageNum = 0 To objPDDoc.GetNumPages() - 1
         Set objPage = objPDDoc.AcquirePage(pageNum)
         Set objHighlight = New AcroHiliteList
         objHighlight.Add 0, 10000 ' Adjust this up if it's not getting all the text on the page
         Set objSelection = objPage.CreatePageHilite(objHighlight)

         If Not objSelection Is Nothing Then
            For tCount = 0 To objSelection.GetNumText - 1
               strText = strText & objSelection.GetText(tCount)
            Next tCount
         End If
      Next pageNum
      objAVDoc.Close 1
   End If

   getTextFromPDF = strText

End Function

标签: vba

解决方案


推荐阅读