PDF Editing Issues

Fix VBA Type Mismatch When Setting PDF List Box Selections in Acrobat

Aamir Naveed AkramAamir Naveed Akram Nov 3, 2026 868 views

Question details

The user needs to set multiple selections in an Acrobat PDF list box using Access VBA, but receives a type mismatch error when passing a VBA integer array to the Acrobat JavaScript Object.

How to Fix VBA Type Mismatch When Setting Multiple PDF List Box Selections
Product
Adobe Acrobat and MS Access VBA
Device & OS
not provided
Scenario
Automating multiple selections in a PDF form list box directly from Microsoft Access VBA via the Acrobat JavaScript Object (JSO) interface.
Observed behavior
Passing a VBA integer array to the currentValueIndices property of an Acrobat PDF list box results in a type mismatch error because VBA objects and JavaScript objects are not directly compatible.
Before you start

Ensure you have full administrative rights to deploy folder-level JavaScript files in your Adobe Acrobat installation directory, and verify your VBA project includes the necessary Acrobat library references.

Solution 1Recommended

Use Folder-Level JavaScript and Pass Strings from VBA

Avoid passing complex objects like arrays across the VBA-to-JavaScript boundary. Instead, pass strings or integers to a pre-defined Acrobat JavaScript function.

Because VBA objects and JavaScript objects function differently, the Acrobat JSO interface cannot natively translate a VBA integer array into a JavaScript array. Attempting to assign a VBA array directly to a built-in property like currentValueIndices will inevitably cause a type mismatch.

The most robust solution is to minimize direct interaction with the JSO from VBA. Move your array-handling logic into Acrobat by creating a folder-level JavaScript function.

1
Create a Folder-Level Script in Acrobat

Navigate to the Acrobat 'Javascripts' folder. Create a new .js file containing a function that accepts a comma-separated string of indices, converts that string into an array, and assigns it to the list box's currentValueIndices property.

2
Convert VBA Array to String

In your MS Access VBA code, iterate through your integer array to construct a single, comma-delimited string (e.g., '0,2,4').

3
Call the JavaScript Function from VBA

Use the Acrobat JSO interface to call your custom folder-level JavaScript function, passing the newly constructed string as a parameter.

Use Folder-Level JavaScript and Pass Strings from VBA
Best Practice: Using folder-level scripts not only prevents type mismatches but also improves automation performance and security within Acrobat.
Free Microsoft Office alternative

Looking for a Simpler Way to Manage Documents and PDFs?

Struggling with complex VBA-to-Acrobat integrations and type mismatch errors? WPS Office offers a streamlined, user-friendly suite for managing text documents, spreadsheets, and PDFs without the heavy developer overhead.

Highly compatible with Microsoft Office formats (.docx, .xlsx, .pptx) for seamless file sharing.Integrated PDF tools to easily edit, fill forms, and manage PDF documents without needing external add-ons.Lightweight, fast, and completely free alternative to expensive and complex legacy software stacks.
QA img-9

Frequently Asked Questions

Why do I get a type mismatch when passing an array from VBA to Acrobat JS?

VBA objects and JavaScript objects have completely different underlying memory structures. The Acrobat JSO interface cannot natively translate a VBA integer array into a JavaScript array, which triggers a type mismatch error when assigning it to properties like currentValueIndices.

Can I use getField to assign an array directly in Access VBA?

No. When you obtain a JavaScript field object via getField in VBA, assigning an array directly to its currentValueIndices property will fail. You must handle the array assignment strictly on the JavaScript side.

What are Acrobat folder-level JavaScript functions?

Folder-level scripts are pre-written JavaScript files saved in the Acrobat application's 'Javascripts' directory. They load securely when Acrobat launches, allowing external applications like Access VBA to execute complex operations by simply calling the function with basic string or integer parameters.