Unable to call .GetJSObject in VBA (Acrobat DC Pro)
Hi,
I'm currently doing some coding task to export pdf files to doc ones. I tried to use batch sequence but Acrobat will eventually pop up error messages or just exist itself for some files. To get the things under control, I tried to use AIC (for excel VBA) to export them one by one, but met barrier for using jso.
I tested the basic AIC function by using the following code and it was working correctly :
Sub test()
Dim AcroApp As Acrobat.CAcroApp
Dim theDocument As Acrobat.CAcroPDDoc
Dim bm As Acrobat.AcroPDBookmark
Dim thePath As String
thePath = "C:\temp\test.pdf"
' Set AcroApp = CreateObject("AcroExch.App")
Set theDocument = CreateObject("AcroExch.PDDoc")
theDocument.Open (thePath)
MsgBox "Number of pages: " & theDocument.GetNumPages
theDocument.Close
' AcroApp.Exit
Set AcroApp = Nothing
Set theDocument = Nothing
Set bm = Nothing
MsgBox "Done"
End Sub
But the following code will fail on line 9, error is "Object variable not set (Error 91)"
Sub test2()
Dim gApp As AcroApp
Dim gPDDoc As AcroPDDoc
Dim jso As Object
Set gApp = CreateObject("AcroExch.App")
Set gPDDoc = CreateObject("AcroExch.PDDoc")
If gPDDoc.Open("C:\temp\test.pdf") Then
jso = gPDDoc.GetJSObject
jso.SaveAs "/c/myDocs/myDoc.xlsx", "com.adobe.acrobat.xlsx"
End If
End Sub
I have referenced the Type Library.

Please let me know if there are anything I can do / try to get the wheel rolling, thank you.
Kind Regards,
Winter
