Question visible home tab in a custom ribbon

Alibaba

New member
Local time
Today, 02:14
Joined
May 29, 2008
Messages
8
Hi,
I am using 3 cutom ribbons in an ADP application. I am loading them using:
Application.LoadCustomUI rs("RibbonName").VALUE, rs("RibbonXml").VALUE

The ribbons are loading fine. On the initial ribbon I am hidding the home tab using the command:
<tab idMso="TabHomeAccess" visible="false" />
in my RibbonXML field.

on the next forms I would like the home tab to be visible again:
<tab idMso="TabHomeAccess" visible="true" />

However unless it is visible on the initial ribbon it will not show on the next ribbon.

any idea on how we can trigger the home tab to referesh or re appear?

thanks
TA.
 
Hi,

you have to invalidate the ribbon to force it to re-validate. in this, you need to set up what the ribbon is to enable it to be re-validated.

so from the beginning-

your Xml needs this code to call when loaded.
<customUI xmlns=http://schemas.microsoft.com/office/2006/01/customui OnLoad="OnRibbonLoad">

to disregard the office tabs
<ribbon startFromScratch="true">

to keep the office tabs
<ribbon startFromScratch="false">

create a module called basRibbon or anything you like but try and keep it related.
in the module make your ribbon groups public and set them as follows. note, i have added text to the begginging of the group names-

Public RbnGrpGroup1 As Boolean
Public RbnGrpGroup2 As Boolean
Public RbnGrpGroup3 As boolean
Public RbnGrpGroup4 As Boolean
Public RbnGrpGroup5 As Boolean

reason they are set as Boolean is because you need to change the visibility on/off or True/False

( GrpGroup1 etc will be the name of the group in the ribbon Xml )

then, make ribbon variable public-
Public gobjRibbon As IRibbonUI

in the module, create the following-

Public Sub OnRibbonLoad(ribbon As IRibbonUI)
'the callback name in the ribbon Xml file as above

Set gobjRibbon = ribbon

'set the visibility of the groups

RbnGrpGroup1 True
RbnGrpGroup2 True
RbnGrpGroup3 True
RbnGrpGroup4 False
RbnGrpGroup5 False

'this will set the ribbon to show groups 1,2 & 3

DoCmd.Openform "YourFormToOpen"
'open a form or enter your startup code. the ribbon code must be run first

End Sub

so, back to the Xml for a minute. each group has a visibility callback. for example-
<group id="RbnGrp1" label="My Group 1" getVisible="GetVisible">

in the basRibbon module, enter the following code-

Public Sub GetVisible(control As IRibbonControl, ByRef visible)
'callback name for the groups in the Xml file "getVisible"

Select Case control.ID

'set the groups to the visible options set in the OnRibbonLoad
Case "GrpGroup1"
visible = RbnGrpGroup1
Case "GrpGroup2"
visible = RbnGrpGroup2
Case "GrpGroup3"
visible = RbnGrpGroup3
Case "GrpGroup4"
visible = RbnGrpGroup4
Case 2 GrpGroup5"
visible = RbnGrpGroup5

Case Else
visible = True
End Select
End Sub

Create a new module called basRibbonMenus

create the menu sets that will determine which groups are on/off

Public Sub Menu1()

'this should be your return menu as loaded
RbnGrpGroup1 True
RbnGrpGroup2 True
RbnGrpGroup3 True
RbnGrpGroup4 False
RbnGrpGroup5 False

'call the code to invalidate the ribbon groups
Call RibbonInvalidate

End Sub

Public Sub Menu2()

'note i have changed groups 3 & 4 visiblity setting.
RbnGrpGroup1 True
RbnGrpGroup2 True
RbnGrpGroup3 False
RbnGrpGroup4 False
RbnGrpGroup5 True
'call the code to invalidate the ribbon groups
Call RibbonInvalidate

End Sub

( do this until all of your menus are set.)

enter this code to invalidate the ribbon-

Public Sub RibbonInvalidate()

gobjRibbon.InvalidateControl "GrpGroup1"
gobjRibbon.InvalidateControl "GrpGroup2"
gobjRibbon.InvalidateControl "GrpGroup3"
gobjRibbon.InvalidateControl "GrpGroup4"
gobjRibbon.InvalidateControl "GrpGroup5"

End Sub

so, what happens.

The ribbon is loaded when the database is opened.
it calls the OnRibbonLoad to get the visibility of the groups
the visibility is changed when the menus are changed.
the ribbon is invalidated to force validation.

next-

In your button code when you want the ribbon to change, call the menu to run the ribbon code.

Public Sub MyButtonThatDoesStuffAndChangesRibbon()

Call Menu2

'your normal code here

End sub

when you have finished and wnat to return the menu back to the original as loaded, you would Call Menu1 which is the same as the started ribbon.


i will place an example but i havent the time today, i will od one tonight and post it tomorrow.

NS
 
Last edited:

Users who are viewing this thread

Back
Top Bottom