Other PDF Issues

How to Programmatically Import PDF Comments Using VBA and JavaScript

Anum MushtaqAnum Mushtaq Nov 24, 2026 868 views

Question details

The user needs to automate the importation and merging of PDF comments and annotations from multiple files into one document without losing formatting or encountering rotation errors.

How to Programmatically Import PDF Comments Using VBA and JavaScript
Product
Excel VBA and Acrobat API
Device & OS
not provided
Scenario
Automating the merging of FDF/XFDF annotation data into a single PDF document using a script.
Observed behavior
Seeking a programmatic method to import annotations because standard OLE classes fail to accurately preserve advanced annotation details and coordinate placement.
Before you start

Ensure you have access to the Adobe Acrobat SDK documentation and have enabled the necessary Acrobat library references within your Excel VBA environment.

Solution 1Recommended

Use the JSObject Bridge via VBA to Import PDF Comments

Utilize the JSObject bridge in your Excel VBA script to leverage Acrobat's JavaScript API for accurate annotation importing.

Standard Adobe Acrobat OLE classes do not fully support advanced annotation functions because they have not been substantially updated since the JSObject was introduced. Using the JSObject bridge allows your VBA code to natively run specific JavaScript commands to handle FDF/XFDF data accurately, preserving exact coordinates.

1
Access the VBA Editor

Open your Excel workbook and press ALT + F11 to launch the VBA Editor.

2
Enable Adobe Acrobat References

Navigate to Tools > References in the top menu and ensure the 'Adobe Acrobat type library' is checked.

3
Initialize Acrobat Objects

Declare and initialize an Acrobat App object (AcroApp) and an AVdoc object in your VBA script to open the target PDF.

4
Instantiate the JSObject Bridge

Retrieve the PDDoc object from your opened AVdoc and instantiate the JSObject bridge using a command such as 'Set jso = pdDoc.GetJSObject'.

5
Run the Import Command

Use the JSObject's native 'importAnns' or 'importAnnsFromData' JavaScript methods within your VBA script to safely and accurately import your FDF/XFDF comments.

Use the JSObject Bridge via VBA to Import PDF Comments
Acrobat SDK Reference: Refer to the Acrobat SDK documentation to fully understand the specific JavaScript methods and parameters available via the JSObject bridge.
Free Microsoft Office alternative

Manage PDF Comments Without Complex Scripts in WPS Office

Avoid the hassle of complicated VBA coding and standard software limitations. WPS Office provides a free, lightweight alternative with high format compatibility and a familiar UI, allowing you to seamlessly handle PDF documents and Excel files in one easy-to-use application.

  1. 1. Download and Install: Download WPS Office from the official website and complete the quick installation process.
  2. 2. Open Your PDF: Launch WPS PDF and open the document containing the comments you need to manage.
  3. 3. Use the Comment Tools: Navigate to the Comment tab on the top ribbon to easily view, add, or export your annotations without writing code.
Free, lightweight, and fast office suite.Excellent compatibility with Microsoft Office formats like .xlsx and .pdf.Built-in, user-friendly PDF editor for viewing and managing annotations intuitively.Familiar UI that ensures a seamless migration without steep learning curves.
microsoft office alternative - wps office

Frequently Asked Questions

Why do my PDF comments lose formatting when imported via VBA OLE classes?

Standard Acrobat OLE classes have limited support for modern annotations and have not been updated to handle complex placement. Using the JSObject bridge provides full access to the Acrobat JavaScript API, which preserves coordinates, formatting, and rotation.

What formats are best for exporting and importing PDF comments programmatically?

FDF (Forms Data Format) and XFDF (XML Forms Data Format) are the standard Adobe formats designed specifically for safely exporting, storing, and importing PDF annotations without altering the main document structure.

How do I access the JSObject in Excel VBA?

You can access the JSObject by opening a PDF using the Acrobat API in VBA, extracting the PDDoc object (which represents the underlying PDF document), and calling the 'GetJSObject' method on it to bridge your script to Acrobat's JavaScript engine.