0
Excel VBA - Save PDF using same name after adding Fields.
Explorer
,
/t5/acrobat-sdk-discussions/excel-vba-save-pdf-using-same-name-after-adding-fields/td-p/15322892
May 15, 2025
May 15, 2025
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
TOPICS
Acrobat SDK and JavaScript
,
Windows
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Have something to add?
Join the conversation

