Hi Michael,
This is part two of my reply, about the Ribbon.
Ribbon GUI:
-----------
This thread has many Ribbon-related links:
http://groups.google.com/group/exceldna/browse_thread/thread/1db415c2700a650b/00edae83397682a1.
The RibbonButton class you refer to is a wrapper class defined in one
of the VSTO libraries. At the moment, Excel-DNA only supports the raw
Excel Ribbon interface - we have no such wrapper layer yet. This means
you have full access to the Ribbon from Excel-DNA, but need to deal
with the 'interesting' interface the Office developers chose to
expose.
For example, to be able to change the label of a button at runtime,
you need to:
* Add a method (say GetLabel) in your ExcelRibbon-derived class that
will return the label of a control.
* Register the GetLabel function in the ribbon xml as the label
handler: getLabel="GetLabel"
* Have some backing property (maybe in a class called MyExcelButton)
that remembers the last label value, which is returned by GetLabel
when the label is asked for.
* When you set the label property, call InvalidateControl("MyButton").
The ribbon will then call your GetLabel function to get the new label
value.
You'd need to do something like this for every property you'd want to
set at runtime.
(This is also what the VSTO wrapper classes do).
If you have a simple ribbon that is not too dynamic, doing this ad-hoc
is probably fine. But for a rich ribbon interface you'd have to make
some wrappers. Doing a wrapper for the whole Ribbon interface would
involve a lot of typing for a few days, but the ribbon is actually
well documented, and once you understand that there are no ribbon
'object' or functions you can call to modify the ribbon, the rest
should be quite straight-forward.
I'd be very happy to help anyone who wants to contribute a wrapper
like this to Excel-DNA.
> Hi,
>
> GUI:
> -------
> I am currently converting an existing VSTO project over to ExcelDNA.
>
> In VSTO, I have control over the form controls (buttons, labels etc)
> within the actions (object sender) via casting the sender object to a
> button etc. This means I can modify the labels etc, buttons etc.
>
> However, within ExcelDNA you get a callback with a IRibbonControl. I
> tried to cast the IRibbonControl to a RibbonButton, but this cast
> failed. I then tried using Marshal.... to investigate the interfaces
> that IRibbonControl extends, but without much success.
>
> Is there a particular method I can use to get access to the underlying
> RibbonButton?
>