PDA

View Full Version : MS Project - Ribbon onLoad and access to the Ribbon Object



Panavia
04-09-2019, 04:18 AM
Hi,

I can't get the onLoad command to work in my Ribbon xml, and can't handover the Ribbon object to a variable in order to dynamically update a button label during runtime.
Once I add the onLoad command to the xml string, I get an automation exception
Does anybody know if this functionality is not there for a MS Project implementation of the Ribbon CustomUI?
Or do you know how realize this any other way?

Please see parts of my code below (I had to change the schema address due to hyperlink failure...).
Thanks!



Option Explicit

Public customRibbon As IRibbonUI


Public Sub ribbon_OnLoad(ribbon As IRibbonUI)
Set customRibbon = ribbon
End Sub

Public Sub ribbonStart_OnAction(control As IRibbonControl)
customRibbon.InvalidateControl "selectStart"
End Sub

Public Sub ribbonStart_GetLabel(control As IRibbonControl, ByRef startLabel)
startLabel = "custom text"
End Sub

Public Sub loadRibbon()
Dim ribbonXml As String
ribbonXml = "<mso:customUI xmlns:mso=""http_schemas.microsoft.com/office/2009/07/customui"" onLoad=""ribbon_OnLoad"" >" & _
"<mso:ribbon>" & _
"<mso:tabs>" & _
' my ribbon
"</mso:tabs>" & _
"</mso:ribbon>" & _
"</mso:customUI>"
ActiveProject.SetCustomUI (ribbonXml)
End Sub