Bart
Bart

Reputation: 68

How to refer to macro in customUI onAction?

I have changed Excel Ribbon accordingly with the tutorial: https://stackoverflow.com/questions/8850836/how-to-add-a-custom-ribbon-tab-using-vba#:~:text=As%20others%20say%2C%20one%20can,file%2C%20with%20xml%20in%20it)

and Microsoft instruction:

https://learn.microsoft.com/en-us/office/vba/library-reference/concepts/customize-the-office-fluent-ribbon-by-using-an-open-xml-formats-file

I Created customUI and it adds all tabs, groups and buttons:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> 
   <ribbon> 
     <tabs> 
       <tab id="eLearningTab" label="E-Learning Tools"> 
         <group id="eLearningMacroes" label="E-Learning Macroes"> 
           <button id="beginEsc" label="Begin E-Learning Escalation" imageMso="NewChessTool" size="large" onAction="openElearningForm"/>
         </group > 
         <group id="esc3" label="Escalation 3"> 
           <button id="openList1" label="Open MDs List" imageMso="BlankPageInsert" size="large" onAction="mdListOpen"/>
           <button id="oNcList" label="Open Noncompliants List" imageMso="BookmarkInsert" size="large" onAction="userListOpen"/> 
           <button id="oSpecMDSh" label="Open specific MD worksheet" imageMso="BibliographyManageSources" size="large" onAction="openTabForm"/> 
           <button id="prepEscF" label="Prepare file for escalation" imageMso="BlogPublish" size="normal" onAction="prepFileForEsc"/> 
           <button id="cMDSha" label="Create MD Worksheets" size="normal" imageMso="BibliographyAddNewSource" onAction="createQueries3rdEsc"/> 
           <button id="sEscMail" label="Send Escalation Mailing" imageMso="NewItemForm" size="normal" onAction="updateForm"/>          
         </group>          
       </tab> 
     </tabs> 
   </ribbon> 
 </customUI> 

The problem is that Excel does not find macroes named in onAction command - in Microsoft tutorial there is a statement "ThisDocument", when I include it in the XML file, i have an error that named Macro was not found.

When I delete it, I got the error that there is wrong number of arguments or invalid property assignment.

I created customization via Excel functionality, exported it and checked how the Excel generates the line, but the statement there refers to the exact excel file FullPath, and I have to distribute the file, so the macro has to be called in the file containing it.

I checked Callback function documentation (https://learn.microsoft.com/en-us/openspecs/office_standards/ms-customui/188cc098-eef7-453e-895c-d96e8e99576c), but did not find the answer.

Do you have any idea how should I edit the XML, to call back the macro correctly?

I would like to ask question under first link above, but I can not add comments yet.

Upvotes: 0

Views: 193

Answers (1)

Lord-JulianXLII
Lord-JulianXLII

Reputation: 1249

Try the following argument for the Subs you are trying to call

Sub onAction(control As IRibbonControl)

End Sub

Upvotes: 1

Related Questions