Fix VBA Type Mismatch When Setting PDF List Box Selections in Acrobat
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.

- 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.
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.
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.
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.
In your MS Access VBA code, iterate through your integer array to construct a single, comma-delimited string (e.g., '0,2,4').
Use the Acrobat JSO interface to call your custom folder-level JavaScript function, passing the newly constructed string as a parameter.

Dynamically Execute JavaScript via AFormAut.App
If you cannot deploy folder-level scripts, you can build and execute a raw JavaScript string dynamically from VBA.
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.

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.




