Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Digitally signing a pdf in using Excel VBA

Community Beginner ,
Jan 10, 2018 Jan 10, 2018

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

TOPICS
Acrobat SDK and JavaScript
7.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 10, 2018 Jan 10, 2018

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
Community Expert ,
Jan 10, 2018 Jan 10, 2018

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 10, 2018 Jan 10, 2018

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 10, 2018 Jan 10, 2018

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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 10, 2018 Jan 10, 2018

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.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 10, 2018 Jan 10, 2018
LATEST

I agree with Thom and Karl that I should setup the scripts in Acrobat and call it from VB.   I was originally playing with the SDK signature javascript example but now I think that solution didnt work because I didn't properly setup the functions in Acrobat first.   I will work with that.  Thanks for your time! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines