none
runtime error -2147467259 (80004005) RRS feed

  • Question

  • I learn to use Excel VBA Code to read and write PDF File

    but Read Code below is done

    Sub ReadAdobeFields()
        row_number = 1

        Dim AcrobatApplication As Acrobat.CAcroApp
        Dim AcrobatDocument As Acrobat.CAcroAVDoc
        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("D:\Test Code\Return for Tax of Salary.pdf", "") Then
            AcrobatApplication.Show
            Set AcroForm = CreateObject("AFormaut.App")
            Set Fields = AcroForm.Fields
            fcount = Fields.Count 'Number of Fields

            For Each Field In Fields
            row_number = row_number + 1
                sFieldName = Field.Name
                'Msgbox sFieldName
                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

        AcrobatApplciation.Exit
        Set AcrobatApplication = Nothing
        Set AcrobatDocument = Nothing
        Set Field = Nothing
        Set AcroForm = Nothing

    End Sub

    =>

    And Write code show Error Runtime -2147467259 (80004005)

    by:

                                        

    Sub WriteToAdobeFields()
        Dim AcrobatApplication As Acrobat.CAcroApp
        Dim AcrobatDocument As Acrobat.CAcroAVDoc
        Dim fcount As Long
        Dim sFieldName As String

        Set AcrobatApplication = CreateObject("AcroExch.App") 'Get Error
        Set AcrobatDocument = CreateObject("AcroExch.AVDoc") 'Get Error

        If AcrobatDocument.Open("D:\Test Code\Return for Tax of Salary.pdf", "") Then
            AcrobatApplication.Show
            Set AcroForm = CreateObject("AFormaut.App")
            Set Fields = AcroForm.Fields
            fcount = Fields.Count

            Fields("Name of Enterprise_0011").Value = "HSL"

        Else
            MsgBox "Failure"
        End If

        AcrobatApplication.Exit
        Set AcrobatApplication = Nothing
        Set AcrobatDocument = Nothing
        Set Field = Nothing
        Set Fields = Nothing
        Set AcroForm = Nothing


    End Sub

    I don't know how to fix it. could you give me a solution? Thanks in advance

    Friday, July 20, 2018 10:31 AM

All replies

  • Hello Khet Samnang,

    This forum(Excel for developers) is for discussing development issue related to Excel Object Model and I think your issue is more related Acrobat API which is a third-part api. I would suggest you contact their support team for help and for the current thread, I will move it Off-Topic  forum.

    Thanks for understanding,

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 23, 2018 2:40 AM