0

I am reading multiple PDF files with VBA using library Adobe Acrobat 10.0 Type Library. It works great except for the corrupted files. If file is corrupted it throws an error in Adobe Acrobat and VBA code is frozen until I confirm the error in Adobe. Is it possible to somehow skip the file or automatically confirm error in VBA. Or maybe turn off notifications in Acrobat. Error that appears is:

Abobe Acrobat DC could not open 'file.pdf' because it is either not a supported file type or because the file was damaged.

enter image description here

Set AcroApp = CreateObject("AcroExch.App")
Set AcroAVDoc = CreateObject("AcroExch.AVDoc")
If AcroAVDoc.Open("corrupted file.pdf", vbNull) <> True Then
    MsgBox("There was an error") 
End If

I was looking online with no luck. Also checked https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/iac_api_reference.pdf

Klemz
  • 123
  • 2
  • 13
  • Have you tried using a VBA Error Handler? https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/on-error-statement – braX Nov 21 '19 at 09:05
  • Yes. It does not work, because VBA do not return error. It is stuck in line: 'If AcroAVDoc.Open("corrupted file.pdf", vbNull) <> True Then' until I confirm the error in Adobe Acrobat. – Klemz Nov 21 '19 at 10:03

0 Answers0