VBA to identify the name of a PDF file that a user has open

NOTE: this requires you have Adobe Acrobat Standard.

Public Function GetOpenPDF()

On Error GoTo Err_Handler

'This works but requires Adobe Acrobat Standard

'This returns the name (but not the path) of the open PDF file

Dim AcroApp As AcroApp

Dim AcroAVDoc As AcroAVDoc

Dim AcroPDDoc As AcroPDDoc

Set AcroApp = CreateObject("AcroExch.App")

Set AcroAVDoc = CreateObject("AcroExch.AVDoc")

Const POSTSCRIPT_LEVEL = 2

Set AcroAVDoc = AcroApp.GetActiveDoc

Set AcroPDDoc = AcroAVDoc.GetPDDoc

GetOpenPDF = AcroPDDoc.GetFileName

Set AcroDoc = Nothing

Set AcroApp = Nothing

Err_Handler:

If Err.Number = 91 Then

MsgBox "Cannot find an open PDF form", vbCritical, "Cannot continue"

Else

Debug.Print Err.Description

Exit Function

End If

End Function