Call a callback to toggle a tab visible/hidden?

X

XP

I want to be able to toggle a Tab visible/hidden on the Ribbon based upon the
contents of a cell.

I have the tab written in XML and the following call back works, but only
each time the file is closed and reopened. How can I make this more fluid so
it updates immediately without having to close and reopen the file? Is there
a way I can call the Callback below to make it run again?

Sub getVisibleCallback(control As IRibbonControl, ByRef visible As Variant)
Dim sShow As String
sShow = [A1].FormulaR1C1
If UCase(sShow) <> "" Then
visible = True
Else
visible = False
End If
End Sub
 
M

Melanie Breden

Hi,

XP said:
I have the tab written in XML and the following call back works, but only
each time the file is closed and reopened. How can I make this more fluid so
it updates immediately without having to close and reopen the file? Is there
a way I can call the Callback below to make it run again?

look at the following example:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="rx_onLoad">
<ribbon>
<tabs>
<tab id="tab_1" label="Custom tab" getVisible="getVisibleCallback" />
</tabs>
</ribbon>
</customUI>

' Modul1
Public objRibbon As IRibbonUI

Public Sub rx_onLoad(ribbon As IRibbonUI)
Set objRibbon = ribbon
End Sub

Public Sub getVisibleCallback(control As IRibbonControl, ByRef visible As Variant)
visible = Worksheets("Sheet1").Range("A1").Value <> ""
End Sub

' Codemodule Sheet1
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) <> "A1" Then Exit Sub
objRibbon.InvalidateControl "tab_1"
End Sub


Mit freundlichen Grüssen
Melanie Breden

- Microsoft MVP für Excel -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top