Skip to main content
Participant
January 17, 2024
Question

Issues in opening Adobe pdf using VBA code

  • January 17, 2024
  • 0 replies
  • 493 views

Hi, I have Adobe Acrobat Reader version 2023.008.20458 64 and I am trying to open the pdf using VBA in excel and the VBA version is 16.0. I am unable to open the pdf with the below code. Tried enabling all adobe acrobat option under References in VB editor, tried repairing Adobe reader etc, and still it is not working. Can some shed some light on how to resolve this issue?

Sub ExtractDataFromOpenPDF()

On Error Resume Next
' Attempt to create an instance of Adobe Acrobat application
Set acrobatApp = CreateObject("AcroExch.App")
On Error GoTo 0

If acrobatApp Is Nothing Then
MsgBox "Error: " & Err.Description
Exit Sub
End If

' Reference to the active PDF document
On Error Resume Next
Set pdfDoc = acrobatApp.GetActiveDoc
On Error GoTo 0

If pdfDoc Is Nothing Then
MsgBox "No PDF document is active. Please open the PDF manually and run the macro again."
Exit Sub
End If

End Sub

This topic has been closed for replies.