Troubleshooting Ribbon Interface complications
The following reference document shows both the VBA and the VB.NET (they call it
Visual Basic) signatures for all the callbacks:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
The ribbon XML is stored in the ProjectName.dna file. For some reason to do with
the Ribbon context, it can only see procedures in the Ribbon handling class. If you
give it any other sub to call, it will not find it. The only ways to connect them are
a) A button onAction with the special value of "RunTagMacro" which is an Excel-Dna
procedure that calls Application.Run(Tag).
It does not pass any parameter to the macro. Be aware that if the tag name already
exists in any other VBA addin loaded before the Excel-Dna XLL addin, that sub will
be run instead. You have to be sure that the Tag is unique.
b) Or, a button has an onAction with a sub name that is present in the Ribbon handler
class. This is the only way of passing the control to the sub which can then examine
the ID and Tag if desired.
Here is some code that illustrates both of those:
<DnaLibrary Name="TasksAnalyzer Add-in" RuntimeVersion="v4.0">
<ExternalLibrary Path="TasksAnalyzer.dll" />
<tab id="Tab_CCTWAVB" label="Tasks Analyzer" keytip="Q" insertAfterMso="TabAddIns">
<group id="CCTWAVBgroup" label="Task Analyzer (VB)">
<button id="CCTWAVBButton1" onAction="RunTagMacro" tag="TA_CountInSelection"
label="Analyze Task" screentip="Analyze Tasks Frequency "
size="normal" imageMso="WordCountList" />
<button id="CCTWAVBButton2" onAction="CCTWAVBButton2" tag="TA_ShowFrmCount"
label="Filter Form" screentip="Show Form to filter analyzed data" size="normal"
The Ribbon class is
Imports ExcelDna.Integration.CustomUI ' needed for IRibbonControl
Imports ExcelDna.Integration.ExcelDnaUtil ' for Application object
Imports System.Runtime.InteropServices ' needed for <ComVisible(True)>
Public Class Ribbon
' implement ExcelDna.Integration.CustomUI.ExcelRibbon to get full Ribbon access.
' Regular Macros can be called from the Ribbon using the onAction='RunTagMacro' helper,
' which calls a macro named in the tag attribute of a button.
' Under the covers, RunTagMacro just calls ExcelDnaUtil.Application.Run(tagName).
'the onAction="MyMacro" attribute will only run methods on the ExcelRibbon-derived class.
'IDs have to be unique, can’t use same ID for something like "RunIDMacro" more than once.