View Full Version : Set a reference to the current ribbon

12-01-2012, 01:09 PM
I want to begin using the IRibbonUI and IRibbonControl objects but I do not know how to get started.

I was thinking maybe something like

Dim theRibbon as IRibbonUI

set theRibbon=activedocument.Ribbon
set theRibbon=application.Ribbon

I know that that does not exist, but how do I set the ribbon control to the current ribbon?

The web is full of articles about how to create a custom ribbon or modify the ribbon. I do not want to do any of that I just want to work with the current ribbon.

When I am done, I will do something like this

For each ribControl in theRibbon
debug.print ribControl.id
next RibControl

So, in Word, Excel, or PowerPoint, how do I set a reference to the current ribbon?

12-02-2012, 06:07 AM

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_OnLoad" >

in the XML and

Public oRibbon As IRibbonUI

'Callback for customUI.onLoad
Public Sub Ribbon_OnLoad(ribbon As IRibbonUI)
Set oRibbon = ribbon
End Sub

in a standard module

That way you can use


to have the ribbon update its setting, etc