View Single Post
 
Old 07-27-2025, 07:09 PM
ayomama ayomama is offline Windows 10 Office 2021
Novice
 
Join Date: Jul 2025
Posts: 5
ayomama is on a distinguished road
Default OnAction function with two string parameters

Hello everyone,

I have already added a dropdown menu and a button as an item of the dropdown menu to Word's ribbon using pre-ribbon era
Code:
Application.CommandBars("Standard").Controls.Add
Word adds the controls under a new "Add-ins" ribbon tab as expected.

The OnAction property of the button is set to :
Code:
'ReplaceTextWithMergeField "@PCIVIL", "PatientTitre"'
Here is ReplaceTextWithMergeField's signature:

Code:
Public Sub ReplaceTextWithMergeField(ByVal macroOrText As String, ByVal mergeFieldNameNew As String)
It is located in a module that does NOT have the statement Option Private Module.


When I click the button I get this error message:


When I assign this parameter-less function (found in the same module) to OnAction instead, it works fine:

Code:
Public Sub Testing()
What am I doing wrong?
Thanks

Last edited by ayomama; 07-27-2025 at 10:18 PM.
Reply With Quote