Ribbon
NormanZ
PowerPoint ®  Stuff

© 2016 All Rights Reserved. Terms and Conditions

SiteLock

Last Updated: July 2016

NormanZ
PowerPoint ®  Stuff

Facebook Page

Customising the ribbon is quite easy provided you get yourself a copy of the Custom UI Editor program from here :-


http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2009/08/07/7293.aspx


Firstly look at my ribbon :-



Customised Office Ribbon






You can see I’ve added a a tab called NormanZ on the ribbon. I have two programs sharing the same ribbon. This is how they look in the Custom UI editor :-


Custom Ribbon Editor Pic1



















Custom Ribbon Editor Pic2


















The ribbon sharing is done by adding  the namespace “NormanZ” which is common to both programs. Then adding  the <tab idQ..> Line at the start of the tabs as shown below :-


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

xmlns:NormanZ="NormanZ" >

<ribbon>

<tabs>

<tab idQ="NormanZ:NormanZTab" label="NormanZ">


The text for the ribbon screen tips and labels is retrieved from your code using these public functions :-


getScreentip="getScreenTip"

getLabel="getLabel"


The quoted strings are the names of the macros that will be invoked. I use functions for this so that they aren’t visible to the end user.


This is a stripped down getLabel() function I use. This is only invoked once when your program starts or when you invalidate the ribbon. This is where you would put your multilingual translations. (See my internationalisation module).


Public Function getLabel(ByVal control As IRibbonControl, ByRef Label) As Boolean

   getLabel = True

   Select Case (control.ID)

   Case "LevelingGroup": Label = “Levelling”)

   Case "btnIdSetLevel": Label = “Add Rule”)

   Case "btnIdInfo": Label = “Rule Info”)

   Case Else: Label = "No Label "

   End Select

End Function


And much the same is the getScreenTip() function:-


Public Function getScreenTip(ByVal control As IRibbonControl, ByRef Screentip) As Boolean

   getScreenTip = True

   Select Case (control.ID)

   Case "btnIdSetLevel": Screentip = “Set Level”

   Case "btnIdInfo": Screentip = “Display Rules List”

   Case "btnIdErase": Screentip = “Clear all Rules”

   Case Else: Screentip = "No Tip"

   End Select

End Function


Invalidating the Ribbon


I use this technique to check my language translations work ok.


First you need to capture a handle to the ribbon when your program starts. I grab this and put it somewhere public:-


Public MyRibbon As IRibbonUI


Sub onLoad(ByVal Ribbon As Office.IRibbonUI)

   

   ' set a reference to the ribbon

   Set MyRibbon = Ribbon

End Sub


Then, if I want to check my translations work with my forms I add some temporary buttons to switch the locale that will be used. This requires a call to my Translation class. So you need to create an instance of the class for the last line in this sub to use.

Sub btnEnglish()

   MyRibbon.Invalidate

   Call tran.setDebugLocale(msoLanguageIDEnglishUS)

End Sub


Sub btnSpanish()

   MyRibbon.Invalidate

   Call tran.setDebugLocale(msoLanguageIDSpanish)

End Sub


Sub btnGerman()

   MyRibbon.Invalidate

   Call tran.setDebugLocale(msoLanguageIDGerman)

End Sub


Etc.

Ribbon