• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Unable to call .GetJSObject in VBA (Acrobat DC Pro)

New Here ,
Dec 25, 2018 Dec 25, 2018

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript

Views

3.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 25, 2019 Sep 25, 2019

Copy link to clipboard

Copied

Hello WinterLi, could you fix this error?
I am trying to convert via VBA macro a PDF file in Excel for processing. I have Acrobat Pro DC.
Can you help me. Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

LATEST

I have the same problem, I try save a pdf file as JPG, but isn't worked for me.

 

Function CreateCertify(ByVal dataUser As Object) 
Dim pdfApp As acrobat.AcroApp '
Dim pdfDoc As acrobat.AcroAVDoc 
Dim SupportDoc As acrobat.AcroPDDoc

Set pdfApp = CreateObject("AcroExch.App")
Set pdfDoc = CreateObject("AcroExch.AVDoc")

If pdfDoc.Open(dataUser("FormatDiploma"), "") = True Then
    pdfApp.Hide    
    Set SupportDoc = pdfDoc.GetPDDoc

    If SupportDoc.Save(PDSaveFull, dataUser("UrlToSave")) = True Then
        Dim jsoObject As Object
        Dim ExportFormat As String
        Dim NewFilePath As String
        Dim boResult As Boolean
        
        Set jsoObject = SupportDoc.GetJSObject
        ExportFormat = "com.adobe.acrobat.jpeg"
        
        NewFilePath = Split(dataUser("UrlToSave"), ".pdf")(0) & ".jpg"
        dataUser.Add "UrlImg", NewFilePath
        
        
        boResult = jsoObject.SaveAs(NewFilePath, ExportFormat) ' This line show error 
        '--------------------------------------------------------

        'NotAllowedError: La configuración de seguridad impide el acceso a esta propiedad o método.
    End If
End If
Exit Function

 

I need help, please!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines