 
           
    
                Acrobatを操作してPDF内のテキストフィールドの値を取得し、イミディエイトウィンドウに結果を出力します。
                ※ 要Acrobat。Readerでは動作しません。
                ※ Acrobat 8 Professional、Acrobat 9 Standardで動作確認しました。
            
                    Option Explicit
                    
                    Public Sub Sample()
                      GetPDFTextFieldValue "D:\TestFiles\MyPDF.pdf"
                    End Sub
                    
                    Public Sub GetPDFTextFieldValue(ByVal InputPath As String)
                      Dim app As Object
                      Dim avdoc As Object
                      Dim pddoc As Object
                      Dim jso As Object
                      Dim f As Object
                      Dim fname As String
                      Dim i As Long
                        
                      Set app = CreateObject("AcroExch.App")
                      Set avdoc = CreateObject("AcroExch.AVDoc")
                      If avdoc.Open(InputPath, vbNullString) = True Then
                        app.Show 'アプリケーション表示
                        'app.Hide 'アプリケーション非表示
                        Set pddoc = avdoc.GetPDDoc
                        If Not pddoc Is Nothing Then
                          Set jso = pddoc.GetJSObject
                          If Not jso Is Nothing Then
                            If jso.numFields > 0 Then
                              Debug.Print "■ " & InputPath & " のテキストフィールドの値"
                              For i = 0 To jso.numFields - 1
                                fname = jso.getNthFieldName(i)
                                Set f = jso.getField(fname)
                                'テキストフィールドのみ処理
                                If LCase$(f.Type) = "text" Then
                                  Debug.Print f.Name, f.Value
                                End If
                                Set f = Nothing
                              Next
                            End If
                            Set jso = Nothing
                          End If
                          Set pddoc = Nothing
                        End If
                      End If
                      
                      '終了処理
                      With app
                        .CloseAllDocs
                        .Hide 'app.Hideしている場合はコメントアウト
                        .Exit
                      End With
                      Set avdoc = Nothing
                      Set app = Nothing
                    End Sub
                
            
