Home>

I would like to use Excel VBA to rewrite the properties (title and author) of the PDF file as described in the excel file.
I tried to do the same with PyPDF2 in Python, but it didn't work so I have a question.

The version of the PDF file to be processed is 1.3 (adobe acrobat 4.x).

When I ran it with code like the following, I got an error (Set a = CreateObject ("AcroExch.PDDoc") is marked in yellow and stopped) at CreateObject ("AcroExch.PDDoc").

If there is any good way, not limited to the code below, I would appreciate it if you could lend me your wisdom.

Sub property rewrite ()
ChDrive ActiveWorkbook.Path
ChDir ActiveWorkbook.Path
ThisPath = ActiveWorkbook.Path&"\"
Filename = Dir (ThisPath&"* .pdf")
    Do While Filename<>""
        Set a = CreateObject ("AcroExch.PDDoc")
            b = a.Open (ThisPath&Filename)
            b = a.SetInfo ("Title", Range ("B1"))
            b = a.SetInfo ("Author", Range ("B2"))
            b = a.Save (ThisPath&Filename)
            b = a.Close
        Filename = Dir ()
    Loop
MsgBox "End of work"
End Sub