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

SDK, JavaScript Object SaveAs no longer working.

New Here ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

Hello.

I have been running the following VBA code without issue for a while. After the latest update to Acrobat Pro DC I have been getting the following error: Save As Failed To Process. No document was created.

 

The code is failing on the JSO.SaveAs line.

Function SaveAs(NewFileName As String) As Boolean
    Dim ExportFormat As String
    Dim extension As String
    extension = "html" ' get the path w/o the "."
    
    Dim acroApp As Object
    Set acroApp = CreateObject("AcroExch.App")
    Dim acroAVDoc As Object
    Set acroAVDoc = CreateObject("AcroExch.AVDoc")
    'if acroApp is nothing then acroApp = CreateObject("AcroExch.App")
    'if acroAVDoc is nothing then acroAVDoc = CreateObject("AcroExch.AVDoc")
    
    Set acroAVDoc = acroApp.GetActiveDoc()
    
    If acroAVDoc Is Nothing Then
        Exit Function
    End If
    
    'Set the PDDoc object.
    Dim acroPDDoc As Object
    Set acroPDDoc = acroAVDoc.GetPDDoc
    
    'Set the JS Object - Java Script Object.
    Dim jso As Object
    Set jso = acroPDDoc.GetJSObject
    
    'Check the type of conversion.
    Select Case LCase(extension)
        Case "eps": ExportFormat = "com.adobe.acrobat.eps"
        Case "html", "htm": ExportFormat = "com.adobe.acrobat.html"
        Case "jpeg", "jpg", "jpe": ExportFormat = "com.adobe.acrobat.jpeg"
        Case "jpf", "jpx", "jp2", "j2k", "j2c", "jpc": ExportFormat = "com.adobe.acrobat.jp2k"
        Case "docx": ExportFormat = "com.adobe.acrobat.docx"
        Case "doc": ExportFormat = "com.adobe.acrobat.doc"
        Case "png": ExportFormat = "com.adobe.acrobat.png"
        Case "ps": ExportFormat = "com.adobe.acrobat.ps"
        Case "rft": ExportFormat = "com.adobe.acrobat.rft"
        Case "xlsx": ExportFormat = "com.adobe.acrobat.xlsx"
        Case "xls":
            ExportFormat = "com.adobe.acrobat.spreadsheet"
            'Note that Adobe instead of xls uses xml files.
    '        newFilename.Replace(extension,"xml")
        Case "txt": ExportFormat = "com.adobe.acrobat.accesstext"
        Case "tiff", "tif": ExportFormat = "com.adobe.acrobat.tiff"
        Case "xml": ExportFormat = "com.adobe.acrobat.xml-1-00"
        Case Else: ExportFormat = "Wrong Input"
    End Select
    
    
    'Check if the format is correct and there are no errors.
    If ExportFormat <> "Wrong Input" Then
        'Save PDF file to the new format.
            Call jso.SaveAs(NewFileName, ExportFormat)
            SaveAs = True
    Else
        SaveAs = False
    End If
    'Release the objects.
    Set jso = Nothing
    Set acroPDDoc = Nothing
    Set acroAVDoc = Nothing
    Set acroApp = Nothing
End Function

 Does anyone have any ideas as to why this just started to fail?

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.0K

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 ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

LATEST

Sometimes you need to cry for help so that you can figure it out yourself. During our latest SCCM update to the latest version the enhanced security was re-enabled. I resolved the issue by turning that off.

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