Here is a simple, functional example. I am replacing simple InputBox prompts instead of trying to recreate your UserForm code, but the general principle should still apply.
I create public variables for username and full name and bAuthenticated (assign your form to these variables or directly access the form). Set bAuthenticated = True after user authentication.
Use the getLabel and update the feed. I create two separate callbacks, one for the username, one for the full name, these are getUserName and getFullName . I also add vba to VisibleGroup , which is called from the getVisible XML getVisible .
Note when making changes to VBA, you will most likely have to save, close and reopen the file, because making these changes can clear all public variables, including the variable, which is a tape. That's why you can get errors from the RefreshRibbon procedure.
Your xml might look like this.
Updated to enable getVisible callback
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="RibbonOnLoad"> <ribbon startFromScratch="false" > <tabs> <tab id="customTab" label="Custom Tab"> <group id="myGroup" label="Hello World" getVisible="VisibleGroup" > <labelControl id="lblUsername" getLabel="getUserName" /> <labelControl id="lblFullname" getLabel="getFullName" /> </group> <group id="mySignin" label="SignIn" visible="true" > <button id="signin" label="Sign In" size="large" supertip="Click this button to sign in." onAction="ribbon_SignIn" tag="SignIn" /> </group> </tab> </tabs> </ribbon> </customUI>
Note. I set the visible property of myGroup to True so that I can more easily verify this. You can use the getVisible same way if you need to change this property at runtime.
And then the callbacks in the VBA module will look something like this:
Option Explicit Public Rib As IRibbonUI Public xmlID As String Public username As String Public fullName As String Public bAuthenticated As Boolean 'Callback for customUI.onLoad Sub RibbonOnLoad(ribbon As IRibbonUI) 'MsgBox "onLoad" Set Rib = ribbon End Sub Sub ribbon_SignIn(control As IRibbonControl) username = InputBox("enter your username", "Your username?") fullName = InputBox("enter your full name", "Your full name?") 'Authenticate bAuthenticated = True VisibleGroup control, bAuthenticated End Sub Sub VisibleGroup(control As IRibbonControl, ByRef returnedVal) returnedVal = bAuthenticated Call RefreshRibbon("myGroup") End Sub Sub getUserName(control As IRibbonControl, ByRef returnedVal) returnedVal = username Call RefreshRibbon(control.id) End Sub Sub getFullName(control As IRibbonControl, ByRef returnedVal) returnedVal = fullName Call RefreshRibbon(control.id) End Sub Sub RefreshRibbon(id As String) xmlID = id 'MsgBox "Refreshing ribbon for " & Id, vbInformation If Rib Is Nothing Then MsgBox "Error, Save/Restart your Presentation" Else Rib.Invalidate End If End Sub