Copy link to clipboard
Copied
Good afternoon,
I've got a PDF that is generated from an excel sheet when the user selects print to pdf. the pdf creates, opens, add's two signature fields and two text fields. Now from a PDF I can go to properties of a signature field and select the this script executes - and have it fill in the date in one of the fields - without issue. What is desired is to have the sheet printed to PDF via the VBA, and allow us to email it to the recipient who can then digitally sign it - and have it populate their date signed field.
But how can I embed that JS via my VBA code? I was referred to look at setAction but it doesn't seem like that would work in my situation? would I have any options?
Thank you!
Copy link to clipboard
Copied
You may need to share your code so that the developers in the community can assist you better.
I would recommend that you reach out to ACP Thom Parker. I've seen him assist other users before with this particular mix of VB and JS.
https://community.adobe.com/t5/user/viewprofilepage/user-id/8591535
Copy link to clipboard
Copied
Thank you for your reply. I didn't have any code yet as I couldn't locate a starting place - or if it was really possible. I will try to reach Mr. Parker.
I create the signature blocks themselves using this as a starting point.
https://www.mrexcel.com/board/threads/convert-excel-to-pdf-with-empty-signature-box.1093353/
Copy link to clipboard
Copied
I 've seen similar posts like yours where some users that work a lot with VB and .Net it is (or may be) possible.
It is not that simple though.
The VB sscript part should be easy as far as the Visual Basic for Applications applications part is concerned.
With JavaScript, on the other hand, since your intent is to embed VB into a JS code that will interface with the PDF document, you may get stuck with security restrictions; in which case, this basically implies that some events need your code to act as a trusted function and execute in a privileged context.
Here are some perfect examples:
Copy link to clipboard
Copied
The VBA script provided by John W at the link you posted is quite good. However, I would suggest you create an Acrobat folder level function for adding all of the PDF features, then call this script from the VBA. Develop this script first, in Acrobat Professional, then go back to the VBA.
You can read about adding fields to a PDF Here: Notice that many of the same functions are used in the article scripts as in the VBA.
https://www.pdfscripting.com/public/PDF-Page-Coordinates.cfm
https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm
You can read about folder level scripts here:
https://www.pdfscripting.com/public/Installing_Automation_Tools.cfm
When a PDF signature field is signed, it generates a Keystroke event. . You can use a keystroke event script to set the date field. This is the same as the "signed" script on the signature field properties dialog.
Set the keystroke script with the "Field.setAction()" function. Here's the reference entry:
If you would rather hire a developer for this task, then please contact me.
Copy link to clipboard
Copied
Thank you for that. I understand the benefits to using the folder level scripts. It makes a lot of sense. But am I correct that the folder script would need to be accessible by anyone who would use the form rather than just creates the PDF?
Copy link to clipboard
Copied
I think that one part of the script has to be saved in the users' current directory, If that is what you meant.
The other part is in the PDF which will handle the events.
I am also learning JavaScript, so I apologize if my attempt to explain something out of my league doesn't make sense.
Copy link to clipboard
Copied
yeah, in my instance a user will be "creating" the PDF via excel VBA. they will then email the PDF to two different people - each who need to sign the form. Neither of the two signers will have access to the folder where the function would be stored.
Copy link to clipboard
Copied
Oh ok, got it!.
The email sending part was answered in this forum a few months ago.
I will try to find that discussion.
But basically what the user who posted the question discovered was, how he was typing the directoy path to the users script portion.
In the end it his issue had nothing to do with emailing and networking, nor privileged context scripting; it had nothing to do with security restrictions either.
He eliminated a few forward or backward slashes from the line of script that had the directoy path to a folder level script... that fixed his problem.
I don't think a full physical path to a directoy in those two users computers is needed though, since the cPath parameter provides and independent temporary pathname to the source file:
cPath: "/C/temp/yourSource.pdf",
Again, I may be wrong and this may or may not apply to your case. But is worth looking into it if you want to resolve the part on how the users will have access to it.
Copy link to clipboard
Copied
The folder level script works with the VBA to create the form and email it to the form filler. The form filler does not need the folder level script. All the form scripts are inside the PDF.
Copy link to clipboard
Copied
Thank you (as usual) for clarifying this and your guidance.
Copy link to clipboard
Copied
ohh indeed. I hadn't realized that part.
Thanks, looking
Copy link to clipboard
Copied
I just though adding to this discussion two more references may be relevant to keep in mind:
Copy link to clipboard
Copied
Thank you, I'm still trying to work on it. Just been pulled away from it.