Skip to main content
Participant
Jan 10, 2018 2:34 PM UTC
Answered

Digitally signing a pdf in using Excel VBA

I have a script that successfully populates data from Excel into a form I have created and saves it.  However, I'm having difficulty digitally signing the form.  The following is old code I found from previous literature and it seems like it should work but it has not yet.  Thanks!

            strSignFName = "C:\misc\Test.pfx"

            Set oSign = objJSO.getField("Test")

'            Set oSign = objJSO.getField("Pool Manager Signature")

            Set oPpklite = objJSO.Security.getHandler("Adobe.PPKLite", True)

          

            oPpklite.login "Test123", "C:\misc\Test.pfx"

            oSign.signatureSign oPpklite

            oPpklite.logout  

          

            'Create the output path, which will be like C:\Users\Christos\Desktop\Forms\01) First Name Last Name.pdf.

            strPDFOutPath = "S:\XXXXX\YYYY\FPU_" & wsF.Cells(i, 7).Value & ".pdf"

          

            'Save the form as new PDF file.

            objAcroPDDoc.Save 1, strPDFOutPath

This topic is closed to new replies. Start a new post to keep the conversation going.
Karl Heinz  Kremer
Karl Heinz KremerCorrect answer
Community Expert
Jan 10, 2018 3:56 PM UTC

I don't have any first hand experience with trying to sign from within VBA (or at least I don't remember if I ever tried), but my experience is that there are some features that cannot be automated via the JSObject, and you will have to write some folder level JavaScript with a function that performs the operation in question, and then call that function from within your VBA code. This may be a case where this is necessary.

5 replies

Legend
Jan 10, 2018 4:22 PM UTC

If it doesn't work a thing to check is the JavaScript console. Anything there?

Translate
Participant
Jan 10, 2018 4:39 PM UTC

Just checked the JS Console.  These were the messages.  Suprised that it says the digital ID is not valid because I have no issue manually signing with this ID.

GeneralError: Operation failed.

Field.signatureSign:0:

[ Creation of this signature could not be completed. ] -> [ You have not selected a valid digital ID. Try again. ]

GeneralError: Operation failed.

Field.signatureSign:0:

[ Creation of this signature could not be completed. ] -> [ You have not selected a valid digital ID. Try again. ]

GeneralError: Operation failed.

SecurityHandler.login:0:

Missing required parameter(s) error

Translate
Thom Parker
Community Expert
Community Expert
Jan 10, 2018 5:44 PM UTC

I would suggest working out the JS code you need for this operation by working in the Console Window, then as Karl suggested, placing it into a folder level function, and calling it from the VBA.

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Karl Heinz  Kremer
Community Expert
Karl Heinz KremerCommunity ExpertCorrect answer
Community Expert
Jan 10, 2018 3:56 PM UTC

I don't have any first hand experience with trying to sign from within VBA (or at least I don't remember if I ever tried), but my experience is that there are some features that cannot be automated via the JSObject, and you will have to write some folder level JavaScript with a function that performs the operation in question, and then call that function from within your VBA code. This may be a case where this is necessary.

Translate