I have an application that adds footers to a pdf - works fine on my desktop but stopped working on my notebook computer - stops at with this error message
Checked VBA references and they are mostly the same
Versions of Acrobat DC are identical
Used to work fine on both machines
Public Function AddPageNumbers(ByVal SourcePath As String, ByVal SourceFileName As String, ByVal DestPath As String, ByVal DestFileName As String, ByVal FrstPg As Double, ByVal MaxNoPgs As Double, ByVal FileNo As Double, ByVal DoYouWantToSendToPrinter As Integer, ByVal FontSize As Integer, ByVal FontColor As String, Optional RotatePageDegrees As Integer, Optional HeaderFooter As String) ', ByVal SupressNoPrintMsg As Boolean) As String '07-25-2011, ByVal DoYouWantToInclPathInFtr As Integer) As String
'https://acrobatusers.com/tutorials/watermarking-a-pdf-with-javascript
Dim ex1 As String
Dim App As Object, AVDoc As Object, AcroPDDoc As Object, AForm As Object
Dim Ret As Long
Dim sString As String * 255
Dim PdfPrint As String, numPages As Integer, numPages1 As Integer, PageNoVar As Integer
Dim sfile As String
Dim sText As String
Dim iFilenum As Integer
Dim filename As String '06-18-2011
Set App = CreateObject("Acroexch.app")
Set AVDoc = CreateObject("AcroExch.AVDoc")
Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
If Right(SourcePath, 1) <> "\" Then SourcePath = SourcePath & "\"
If Right(DestPath, 1) <> "\" Then DestPath = SourcePath & "\"
filename = DestFileName '06-18-2011
booleanresult = AVDoc.Open(SourcePath & SourceFileName, "")
If booleanresult = True Then
Set AcroPDDoc = AVDoc.GetPDDoc
If Not IsNull(RotatePageDegrees) Then
numPages = AcroPDDoc.GetNumPages()
For PageNoVar = 0 To numPages - 1
Dim PDFPage As AcroPDPage
Set PDFPage = AcroPDDoc.AcquirePage(PageNoVar)
Call PDFPage.SetRotate(0)
Call PDFPage.SetRotate(RotatePageDegrees)
Next
End If
' MsgBox numPages
PageNoVar = 0
While PageNoVar <= numPages
ex1 = "this.addWatermarkFromText({" & vbLf
' ex1 = ex1 & "cText: " & """" & "DRAFT\n\nCOPY" & """" & "," & vbLf
' ex1 = ex1 & "for (var p = 0; p < this.numPages; p++) " & vbLf
ex1 = ex1 & "cText: " & """" & filename & " -- " & Format(Now(), "mm-dd-yyyy hh:mm") & " " & PageNoVar + 1 & " of " & numPages & """" & "," & vbLf
' ex1 = ex1 & """" & " -- Page: "" + String(p+1)+ ""/"" + this.numPages " & """" & "," & vbLf
ex1 = ex1 & "nTextAlign:app.constants.align.center," & vbLf
If HeaderFooter = "Header" Then
ex1 = ex1 & "nVertAlign:app.constants.align.top," & vbLf
Else
ex1 = ex1 & "nVertAlign:app.constants.align.bottom," & vbLf
End If
ex1 = ex1 & "cFont: " & """" & "Helvetica-Bold" & """" & "," & vbLf
ex1 = ex1 & "nFontSize: " & FontSize & "," & vbLf
ex1 = ex1 & "aColor: color.red," & vbLf
ex1 = ex1 & "nStart: " & PageNoVar & "," & vbLf
ex1 = ex1 & "nOpacity: 0.5" & vbLf
ex1 = ex1 & "});"
PageNoVar = PageNoVar + 1
AForm.Fields.ExecuteThisJavaScript ex1
Wend
End If
On Error Resume Next
AcroPDDoc.Save 1, DestPath & DestFileName
numPages = AcroPDDoc.GetNumPages()
sfile = DestPath & "Files Printed " & Format$(Now, "YYMMDD") & ".txt"
sText = IIf(FileNo < 10, "00", IIf(FileNo < 100, "0", "")) & FileNo & " --- " & "Printed " & MaxNoPgs & " of " & IIf(numPages < 10, "00", IIf(numPages < 100, "0", "")) & numPages & " --- " & SourcePath & SourceFileName & " --- " & DestPath & DestFileName
If FileNo = 1 Then Kill DestPath & "Files Printed " & Format$(Now, "YYMMDD") & ".txt"
iFilenum = FreeFile
Open sfile For Append As iFilenum
Write #iFilenum, sText
Close #iFilenum
If MaxNoPgs >= numPages Then
MaxNoPgs = numPages
End If
On Error GoTo 0
AcroPDDoc.Close
AVDoc.Close (True)
App.Exit
Set AcroPDDoc = Nothing
Set AVDoc = Nothing
Set App = Nothing
If DoYouWantToSendToPrinter = 6 Then
'http://help.adobe.com/livedocs/acrobat_sdk/10/Acrobat10_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Acrobat10_SDK_HTMLHelp&file=DevFAQ_UnderstandingSDK.22.31.html
appPDF = """" & "C:\Program Files (x86)\Adobe\Acrobat dc\Acrobat\Acrobat.exe" & """"
RetVal = Shell(appPDF & " /t /h /s /o " & """" & DestPath & DestFileName & """" & " Adobe PDF", 0)
Else
End If
End Function
I'm baffled
My guess is that the AForm object is not being created (maybe a missing reference to the AFormAut library?) but that's just my gut feeling based on where the error is happening. It may just be a library that somehow got moved or is missing for some reason on the one PC.