none
Ribbon button callbacks in other languages RRS feed

  • Question

  • Hello,

    My question relates to callbacks for custom ribbon buttons created (or repurposed Office Ribbon buttons). We can write these callback methods in either VBA or in managed add-ins using VSTO. But I was wondering if there is a way to use COM/OLE and have these callback implementations written in some other programming language. So when the user clicks that button (or executes that command), the implementation written in the other language is called (similar to events that are bubbled up and exposed via COM/OLE and can thus be captured in applications written in any language that understands COM/OLE.)

    If anyone has any known work-arounds to achieve this, I will appreciate if you can share those details.

    Thanks
    Satish

    Tuesday, January 10, 2012 10:59 AM

Answers

  • Hi Satish

    You can listen to Ribbon "event" by using the Ribbon Accessibility API. That could even give you a small amount of control. I've never really used it, so I can't say for sure:

     

    <<You mentioned that I could call via an in-process stub - could you elaborate? Do you mean that I could use VBA to load a DLL and do the appropriate calls in the callback method?>>

     

    Yes. As long as the DLL is COMVisible and COM Registered (and it sounds like that's the case). Here's an article that's for VSTO Add-ins, but it does cover the basics of what's necessary and could help guide you:
    http://msdn.microsoft.com/en-us/library/bb608614.aspx


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bruce Song Wednesday, January 18, 2012 6:51 AM
    Tuesday, January 10, 2012 4:54 PM
    Moderator

All replies

  • Hi Satish

    The callbacks for the Ribbon must, by design, be in-process with the Office application. The Ribbon cannot be controlled by any outside source. So the callbacks must be in a document or a COM Add-in. If you want to call outside code, then you'd need a stub in-process that makes the call to a DLL or something.


    Cindy Meister, VSTO/Word MVP
    Tuesday, January 10, 2012 2:18 PM
    Moderator
  • Hi Cindy,

    Thanks for that tip. In our case, we listen to events from the Office application via COM/OLE. So I wondered if there was something that could also let me plug-in my non-VBA code to the Ribbon callback. Good to have it cleared up.

    You mentioned that I could call via an in-process stub - could you elaborate? Do you mean that I could use VBA to load a DLL and do the appropriate calls in the callback method?

    Thanks again
    Satish

    Tuesday, January 10, 2012 2:33 PM
  • Hi Satish

    You can listen to Ribbon "event" by using the Ribbon Accessibility API. That could even give you a small amount of control. I've never really used it, so I can't say for sure:

     

    <<You mentioned that I could call via an in-process stub - could you elaborate? Do you mean that I could use VBA to load a DLL and do the appropriate calls in the callback method?>>

     

    Yes. As long as the DLL is COMVisible and COM Registered (and it sounds like that's the case). Here's an article that's for VSTO Add-ins, but it does cover the basics of what's necessary and could help guide you:
    http://msdn.microsoft.com/en-us/library/bb608614.aspx


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bruce Song Wednesday, January 18, 2012 6:51 AM
    Tuesday, January 10, 2012 4:54 PM
    Moderator