Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-29-2025, 04:31 AM
ayomama ayomama is offline OnAction function with two string parameters Windows 10 OnAction function with two string parameters Office 2021
Novice
OnAction function with two string parameters
 
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
 

Tags
onaction parameters



Similar Threads
Thread Thread Starter Forum Replies Last Post
Public function string problem JamesWood Word VBA 3 05-27-2021 11:55 PM
Calling a macro from a template using OnAction sg11 Word VBA 2 04-30-2018 11:43 PM
OnAction function with two string parameters How to get the Right function to return a string that has UPPERCASE letters only adj Word VBA 9 08-30-2014 09:21 PM
OnAction function with two string parameters .OnAction only works in document with the code donbexcel Word VBA 1 11-02-2011 05:25 AM
OnAction function with two string parameters Macro or Function to know wether a string is included in a text Eduardo Word VBA 5 06-15-2009 01:55 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:03 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft