VBA:在没有Acrobat DC的情况下读取/写入PDF

时间:2019-08-12 16:07:32

标签: excel vba pdf adobe

我很难找到我的问题的直接答案,所以我以为我会转过来。我正在努力能够读取PDF,也可以使用VBA和Excel编写PDF。我已经成功编写了从PDF文档中读取的代码...

Sub ReadAdobeFields()
Dim row_number As Integer
row_number = 1

Dim AcrobatApplication As Acrobat.AcroApp
Dim AcrobatDocument As Acrobat.AcroAVDoc
Dim fcount As Long
Dim sFieldName As String

On Error Resume Next
Set AcrobatApplication = CreateObject("AcroExch.App")
Set AcrobatDocument = CreateObject("AcroExch.AVDoc")

If AcrobatDocument.Open("C:\thefile", "") Then
    AcrobatApplication.Show
    Set AcroForm = CreateObject("AFormAut.App")
    Set Fields = AcroForm.Fields
    fcount = Fields.Count

        For Each field In Fields
            row_number = row_number + 1
            sFieldName = field.Name

            Sheet1.Range("B" & row_number) = field.Name
            Sheet1.Range("C" & row_number) = field.Value
            Sheet1.Range("D" & row_number) = field.Style

        Next field

Else
    MsgBox "failure"

End If

AcrobatApplication.Exit
Set AcrobatApplication = Nothing
Set AcrobatDocument = Nothing
Set field = Nothing
Set Fields = Nothing



End Sub

但是我只有在下载Adobe Acrobat DC的免费试用版后才能执行此操作,以便能够使用正确的参考。我想知道是否有一种方法可以使用免费软件(例如Adobe Reader)来完成与上述相同的工作,并且还可以将PDF写入PDF。

谢谢!

0 个答案:

没有答案