Skip to main content
Participant
October 11, 2023
Question

Adobe Acrobat PRO -> after update there is a problem to Export PDF to Excel by VBA

  • October 11, 2023
  • 0 replies
  • 366 views

Hi there.

My VBA macro worked always without any problems. 

After last update Adobe Acrobat, I cant export PDF to XLSX

Sometimes it works but mostly time exacly same file, with same settings and same PDF to convert doesnt work.

 

I get a problem in line

boResult = objAcroAVDoc.Open(PDFPath, "")

 

with error message

Run-time error -2147023170 (800706be)

Automation error

On another computer with older version I dont have that problem at all.

 

Sometimes helps restart a computer, but afterm convert some PDF problem returns.

 

Any idea what can help?

or is there a way to downgrade Adobe Acrobat PRO to previous version?

 

VBA

Private Sub SavePDFAs(PDFPath As String, FileExtension As String, wiersz As Integer)
  
   
    Dim objAcroApp      As Acrobat.AcroApp 'Object '
    Dim objAcroAVDoc    As Acrobat.AcroAVDoc 'Object '
    Dim objAcroPDDoc    As Acrobat.AcroPDDoc 'Object '
    Dim objJSO          As Object
    Dim boResult        As Boolean
    Dim ExportFormat    As String
    Dim NewFilePath     As String
       

    Set objAcroApp = CreateObject("AcroExch.App")
    Set objAcroAVDoc = CreateObject("AcroExch.AVDoc")
    boResult = objAcroAVDoc.Open(PDFPath, "")
    Set objAcroPDDoc = objAcroAVDoc.GetPDDoc
    Set objJSO = objAcroPDDoc.GetJSObject
   
    'Check the type of conversion.
    Select Case LCase(FileExtension)
        Case "xlsx": ExportFormat = "com.adobe.acrobat.xlsx"
        Case "xls": ExportFormat = "com.adobe.acrobat.spreadsheet"
        Case Else: ExportFormat = "Wrong Input"
    End Select
   
    'Check if the format is correct and there are no errors.
    If ExportFormat <> "Wrong Input" And Err.Number = 0 Then
        If LCase(FileExtension) <> "xls" Then
            NewFilePath = WorksheetFunction.Substitute(PDFPath, ".pdf", "." & LCase(FileExtension))
        Else
            NewFilePath = WorksheetFunction.Substitute(PDFPath, ".pdf", ".xml")
        End If
       
        'Save PDF file to the new format.
        boResult = objJSO.SaveAs(NewFilePath, ExportFormat)
        
        Worksheets("PDF").Range("H" & wiersz).Value = NewFilePath
        
        Dim Pozycja As Integer
        Pozycja = LastpositionOfChar(NewFilePath, "\")
        
        Worksheets("PDF").Range("I" & wiersz).Value = Right(NewFilePath, Len(NewFilePath) - Pozycja)
        boResult = objAcroAVDoc.Close(True)
       
        'Close the Acrobat application.
        boResult = objAcroApp.Exit
       
    Else
        boResult = objAcroAVDoc.Close(True)
        boResult = objAcroApp.Exit
    End If
       
    'Release the objects.
    Set objAcroPDDoc = Nothing
    Set objAcroAVDoc = Nothing
    Set objAcroApp = Nothing
       
End Sub

 

This topic has been closed for replies.