A
Axel
Hi,
in Word 2007 there is a global template "TEST.DOTM". Within the ribbon of
this template I've created the new tab "Test" wich contains 5 button.
Depending on user setting, some of these button should be visible and some
should not - after TEST.DOTM is loaded as global template. Here is the code:
XML code:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="CallbackOnRibbonLoad">
<ribbon startFromScratch="false">
<tabs>
<tab id="MyTab" label="Test">
<group id="MyGroup" label="Testgroup">
<buttonGroup id="MyButtonGroup">
<button id="Button1" imageMso="_1"
getVisible="CallbackGetVisible" tag="Macro1" />
<button id="Button2" imageMso="_2"
getVisible="CallbackGetVisible" tag="Macro2" />
<button id="Button3" imageMso="_3"
getVisible="CallbackGetVisible" tag="Macro3" />
<button id="Button4" imageMso="_4"
getVisible="CallbackGetVisible" tag="Macro4" />
<button id="Button5" imageMso="_5"
getVisible="CallbackGetVisible" tag="Macro5" />
</buttonGroup>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
VBA code:
Public gobjRibbon As IRibbonUI
Public gbooRibbonButtonVisible As Boolean
'Global variable gobjRibbon intitialize at startup:
Public Sub CallbackOnRibbonLoad(ribbon As IRibbonUI)
Set gobjRibbon = ribbon
gbooRibbonButtonVisible = False 'All button fade out
End Sub
'Button visible/not visible:
Public Sub CallbackGetVisible(control As IRibbonControl, ByRef visible As
Variant)
visible = gbooRibbonButtonVisible
End Sub
Public Sub AutoExec()
Dim astrAllMacros(5) As String
Dim intI As Integer, strX As String
astrAllMacros(1) = "Button1"
astrAllMacros(2) = "Button2"
astrAllMacros(3) = "Button3"
astrAllMacros(4) = "Button4"
astrAllMacros(5) = "Button5"
gbooRibbonButtonVisible = True
strX = "10101" 'Only "Button1", "Button3" and "Button5" should be visible
For intI = 1 To 5
If Mid(strX, intI, 1) = "1" Then gobjRibbon.InvalidateControl
astrAllMacros(intI)
Next intI
End Sub
After that actually only "Button1", "Button3" and "Button5" should be
visible, but there are ALL button visible. Why?
I hope someone can help me.
Thanks in advance!
Axel
in Word 2007 there is a global template "TEST.DOTM". Within the ribbon of
this template I've created the new tab "Test" wich contains 5 button.
Depending on user setting, some of these button should be visible and some
should not - after TEST.DOTM is loaded as global template. Here is the code:
XML code:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="CallbackOnRibbonLoad">
<ribbon startFromScratch="false">
<tabs>
<tab id="MyTab" label="Test">
<group id="MyGroup" label="Testgroup">
<buttonGroup id="MyButtonGroup">
<button id="Button1" imageMso="_1"
getVisible="CallbackGetVisible" tag="Macro1" />
<button id="Button2" imageMso="_2"
getVisible="CallbackGetVisible" tag="Macro2" />
<button id="Button3" imageMso="_3"
getVisible="CallbackGetVisible" tag="Macro3" />
<button id="Button4" imageMso="_4"
getVisible="CallbackGetVisible" tag="Macro4" />
<button id="Button5" imageMso="_5"
getVisible="CallbackGetVisible" tag="Macro5" />
</buttonGroup>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
VBA code:
Public gobjRibbon As IRibbonUI
Public gbooRibbonButtonVisible As Boolean
'Global variable gobjRibbon intitialize at startup:
Public Sub CallbackOnRibbonLoad(ribbon As IRibbonUI)
Set gobjRibbon = ribbon
gbooRibbonButtonVisible = False 'All button fade out
End Sub
'Button visible/not visible:
Public Sub CallbackGetVisible(control As IRibbonControl, ByRef visible As
Variant)
visible = gbooRibbonButtonVisible
End Sub
Public Sub AutoExec()
Dim astrAllMacros(5) As String
Dim intI As Integer, strX As String
astrAllMacros(1) = "Button1"
astrAllMacros(2) = "Button2"
astrAllMacros(3) = "Button3"
astrAllMacros(4) = "Button4"
astrAllMacros(5) = "Button5"
gbooRibbonButtonVisible = True
strX = "10101" 'Only "Button1", "Button3" and "Button5" should be visible
For intI = 1 To 5
If Mid(strX, intI, 1) = "1" Then gobjRibbon.InvalidateControl
astrAllMacros(intI)
Next intI
End Sub
After that actually only "Button1", "Button3" and "Button5" should be
visible, but there are ALL button visible. Why?
I hope someone can help me.
Thanks in advance!
Axel