Is it possible to start a "ribbon-procedure" (void DoSomething(IRibbonControl control)) also directly from excel?
e.g. in an VBA-sub or with "start macro"?
Or is it possible to react to a keystroke (e.g. F5)?
Hi Albrecht,
Please start a new discussion for new questions – that helps future me and others find the relevant topic more easily.
It’s not easy to call the ribbon procedure from VBA.
But you can define and register macro commands in your add-in like this
[ExcelCommand(ShortCut ="{F5}")] // Or something like "^w" to mean Ctrl + w
public static void DoTheWork()
{
var app = ExcelDnaUtil.Application as Application;
app.ActiveSheet.Range["A1"].Value = "Hello from a command!";
}
Such a macro can be:
You can directly add a shortcut to the ExcelCommand definition, as above, but sometimes you cannot override the built-in shortcuts this way, so "^c" (Ctrl + C) won’t work.
-Govert