Copy link to clipboard
Copied
I have a sub that opens a PDF, adds a couple signature fields to it, and then saves the file. All works well if I save the file to a different name, but I need to save the file using the same file name, but it's not working like it used to. Thank you.
Code:
Sub AddSigFields(docName As String, SignLeft As Boolean, SignRight As Boolean)
Dim AcroApp As Acrobat.CAcroApp
Dim pdDoc As Acrobat.CAcroPDDoc
Dim avDoc As Acrobat.CAcroAVDoc
Dim JSO As Object
Dim SignField As Object
'I omitted the code that defines the SigCoord arrays. Not the problem.
Set AcroApp = CreateObject("AcroExch.App")
Set avDoc = CreateObject("AcroExch.AVDoc")
If avDoc.Open(docName, "") Then
Set pdDoc = avDoc.GetPDDoc
Set JSO = pdDoc.GetJSObject
If SignLeft Then
Set SignField = JSO.AddField("SigFieldLeft", "signature", 0, SigCoordsLeft)
End If
If SignRight Then
Set SignField = JSO.AddField("SigFieldRight", "signature", 0, SigCoordsRight)
End If
If pdDoc.Save(PDSaveFull, docName) Then
pdDoc.Close
avDoc.Close False
Else
MsgBox "Unable to save PDF:" & vbcrlf & docName
End If
Else
MsgBox "Document not found:" & vbCrLf & docName
End If
Set SignField = Nothing
Set JSO = Nothing
Set pdDoc = Nothing
Set avDoc = Nothing
Set AcroApp = Nothing
End Sub
Have something to add?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now