PDF Editing Issues

How to Run JavaScript When a PDF Signature Field is Signed

Phi Hung VoPhi Hung Vo Nov 3, 2026 869 views

Question details

The user wants to automatically populate a date field when a recipient signs a PDF document created via Excel VBA and Acrobat.

How to Run JavaScript When a PDF Signature Field is Signed
Product
Adobe Acrobat, Excel VBA
Device & OS
not provided
Scenario
Automating PDF workflows where a date field needs to be filled automatically upon the execution of a digital signature.
Observed behavior
Looking for a method to trigger a script to auto-fill the date field when a signature field generates an event in a PDF.
Before you start

Ensure you have Adobe Acrobat Professional installed to develop and test your JavaScript code before integrating it with your Excel VBA project.

Solution 1Recommended

Use Acrobat JavaScript to Trigger a Keystroke Event

Assign an event script to the signature field using the Field.setAction() method to populate the date field upon signing.

When a PDF signature field is signed, it generates a keystroke event. You can use a keystroke event script to set the date field, just as you would with the Signed script in the signature field properties.

It is highly recommended to develop the script first in Acrobat Professional to ensure the logic works correctly, and then integrate it with your VBA workflow.

1
Create a folder-level script

In Adobe Acrobat Professional, create an Acrobat folder-level function to house all your reusable PDF feature scripts. This ensures the functions are globally accessible when called.

2
Assign the action to the signature field

Use the Field.setAction() method within your script to assign a keystroke event to the target signature field.

3
Configure the date population

Write the keystroke event script so that it targets your specific date field and populates it with the current date when the signature keystroke event is detected.

4
Call the function from VBA

In your Excel VBA script, use the Acrobat API (AcroExch) to execute the folder-level JavaScript function you created, applying the behavior to the newly generated PDF.

Use Acrobat JavaScript to Trigger a Keystroke Event
API Reference: Refer to the official Acrobat JavaScript API documentation for detailed syntax on the Field.setAction() function and setting up folder-level scripts.
Simplify PDF Management

Edit and Sign PDFs Effortlessly with WPS Office

While scripting with Excel VBA and Acrobat can be highly complex, WPS Office provides a streamlined, built-in PDF editor that makes adding signatures, text fields, and dates simple and intuitive without requiring advanced coding skills.

  1. 1. Open your PDF: Launch WPS Office and open your PDF document using the built-in PDF editor.
  2. 2. Access the signing tools: Navigate to the 'Fill & Sign' or 'Protect' tab located on the top ribbon.
  3. 3. Add your signature: Click on 'Sign' to create a new digital signature or insert an existing one into the designated document field.
  4. 4. Insert the date manually: Use the 'Add Text' tool to easily input the current date next to your signature, bypassing the need for complex JavaScript event listeners.
Native PDF form filling and signature support without complex scriptingFully compatible with Microsoft Excel and standard PDF formatsLightweight, fast, and highly intuitive user interface
microsoft office alternative - wps office

Frequently Asked Questions

What event is triggered when a PDF signature field is signed?

When a PDF signature field is signed, it inherently generates a keystroke event in Acrobat. You can bind a JavaScript function to this specific event to execute subsequent actions, such as auto-filling a date field.

Where should I develop my Acrobat JavaScript before using VBA?

It is highly recommended to develop and test your JavaScript directly inside Adobe Acrobat Professional first. Once verified, you can place the reusable functions into an Acrobat folder-level script and call them seamlessly via Excel VBA.

Can I use VBA to directly manipulate PDF fields without JavaScript?

While Excel VBA can interact with the Acrobat application via the AcroExch API to extract or set basic data, configuring dynamic field-level event triggers (like actions upon signing) typically requires injecting or calling Acrobat JavaScript.