Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-27-2025, 07:09 PM
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 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
 

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 07:52 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