View Single Post
 
Old 07-29-2025, 04:31 AM
ayomama ayomama is offline Windows 10 Office 2021
Novice
 
Join Date: Jul 2025
Posts: 5
ayomama is on a distinguished road
Default

Sharing my solution.


Based on comments from ms word - VBA Pass arguments with .onAction - Stack Overflow and Just a moment...


The only consistent method to pass multiple parameters to a callback function is through the .Parameter property of the control.


Step 1 - define the callback function without any parameters in its signature
Step 2 - set the value of the .OnAction property of the button (or other control) to the name of the function
Step 3 - set the value of the .Parameter of the button (or other control) to a concatenated string of parameters
Step 4 - in the callback function, read CommandBars.ActionControl.Parameter to retrieve the concatenated parameters
Step 5 - use Split() to retrieve the individual parameters


Will try to add sample code to illustrate later.
Reply With Quote