Copy link to clipboard
Copied
Have simple VBA function to determine wheather a pdf is 8x11 or not.
If there are no other PDFs open, function runs without error.
If another PDF is open the CreateObject("acroexch.pddoc") Fails.
Error Number: -2146959355
Error Description: Server execution failed
Code:
ublic Function funGetPdfPageSize(ByVal strAbsFName As String) As Boolean
On Error GoTo Err_Handler
Dim gApp As Acrobat.CAcroApp
Dim gPDDoc As Acrobat.CAcroPDDoc
Dim pdfPage As Object
Dim strFunName As String, strErrMsg As String
Dim width As Double
Dim height As Double
strFunName = "funGetPdfPageSize"
funGetPdfPageSize = False
If LCase(right(strAbsFName, 3)) <> "pdf" Then Err.Raise 65000, , "The input file is not a PDF file!"
'Set gApp = CreateObject("acroexch.app")
Set gPDDoc = CreateObject("acroexch.pddoc")
If gPDDoc.Open(strAbsFName) Then
Set pdfPage = gPDDoc.AcquirePage(0).GetSize()
height = pdfPage.Y / 72
width = pdfPage.x / 72
'Debug.Print width
'Debug.Print height
If height <> 11 Or width <> 8.5 Then
If height <> 8.5 Or width <> 11 Then
Err.Raise 65000, , "Page size of PDF needs to be 8.5 X 11. Please print and scan to yourself."
End If
End If
End If
funGetPdfPageSize = True
Exit_Proc:
'Set gApp = Nothing
Set gPDDoc = Nothing
Set pdfPage = Nothing
Exit Function
Err_Handler:
strErrMsg = "The following error has occurred in " & strFunName & "." & vbCrLf
strErrMsg = strErrMsg & "Error Number: " & Err.Number & vbCrLf
strErrMsg = strErrMsg & "Error Description: " & Err.Description & vbCrLf
strErrMsg = strErrMsg & "Error Source: " & Err.Source & vbCrLf
strErrMsg = strErrMsg & "Last DLL Error: " & Err.LastDllError & vbCrLf
strErrMsg = strErrMsg & "Help Context: " & Err.HelpContext & vbCrLf
strErrMsg = strErrMsg & "Help File: " & Err.HelpFile & vbCrLf
MsgBox strErrMsg
Resume Exit_Proc
End Function
Adobe acrobat standard DC
Continuous release version 2021.011.20039
Copy link to clipboard
Copied
One thing to check: make sure Protected Mode is OFF (Enhanced Security preferences).
Copy link to clipboard
Copied
Unchecked Protected mode and issue persists, sorry did not mention that on original post.