I am experimenting with a template add-in that will create several variations of a custom tab based on the network username of the user. Since I am working with a stand alone PC without access to a network I similute different usernames with a inputbox and an AutoOpen procedure in the template.

[VBA]Sub AutoOpen()
pUserName = InputBox("Enter one of the following user names for this demo (Robert Jones, Greg Maxey, Tim Smith, Betty Rogers", "UserName")
End Sub
[/VBA]

The username created is then used with a GetVisible callback to determine which custom groups to display:

[VBA]Sub GetVisible(control As IRibbonControl, RtnVal)
Select Case control.ID
Case "GrpFrontOffice"
Select Case pUserName
Case "Tim Smith", "Mary Allen", "Betty Rogers"
RtnVal = True
Case Else
RtnVal = False
End Select
Case "GrpDrJones"
If pUserName = "Robert Jones" Then RtnVal = True Else: RtnVal = False
Case "GrpCDRMaxey"
If pUserName = "Greg Maxey" Then RtnVal = True Else: RtnVal = False
End Select
End Sub[/VBA]

All seemed to be working great until I closed down Word and restarted Word.

It seems that there is a difference in how the ribbon is loaded when Word is first started.

When I shutdown and restart Word and then open my template the custom tab is already displayed before the AutoOpen procedure fires to define the username. After that name is provided nothing happens.

If I close the document (but not Word) and then reopen the document, the custom tab is not displayed. The AutoOpen macro fires and after a username is provided the correct custom tab configuration is displayed.

To get around this behaviour I altered my AutoOpen procedure as shown:

[VBA]Sub AutoOpen()
pUserName = InputBox("Enter one of the following user names for this demo (Robert Jones, Greg Maxey, Tim Smith, Betty Rogers", "UserName")
On Error Resume Next
rxIRibbonUI.Invalidate
End Sub
[/VBA]

Is there a reason the ribbon loading sequence is different when Word is first started and is there another (or better way) to control how it loads in situations like this?

Sample document attached.