Enable/grey out ribbon custom icon

Wysy

Registered User.
Local time
Today, 14:15
Joined
Jul 5, 2015
Messages
333
Hi,
I have a custom icon in the ribbon that is actually based on a macro. The macro has a function in a form. I would like to have this macro based icon enabled (not greyed out ) only if that specific form is open. I do not want to have the customized ribbon load depending on the form open. I simply would like to enable/disable the visible ribbon icon with condition.
thanks
Andy
 
I will go through it. Thank you
I would like to customize the ribbon so certain controls getenabled only if some certain forms are open, otherwise they should be greyed out, disabled.
 
use tempvars to enable/disable your icon:
Code:
Sub OnRibbonLoad(ribbon As IRibbonUI)
' Callbackname in XML File "onLoad"

    Set gobjRibbon = ribbon

    SetUpTempVars
End Sub

Sub GetEnabled(control As IRibbonControl, ByRef enabled)
' Callbackname in XML File "getEnabled"

' To set the property "enabled" to a Ribbon Control
' For further information see: http://www.accessribbon.de/en/index.php?Downloads:12
' Setzen der Enabled Eigenschaft eines Ribbon Controls
' Weitere Informationen: http://www.accessribbon.de/index.php?Downloads:12

    Select Case control.ID
    Case "btn01", "btn02", "btn03", "btn04", "btn05", _
         "btnExit", "btnUser", "btnLogin"
        enabled = TempVars("Ribbon_" & control.ID)

    Case Else
        enabled = True

    End Select

End Sub



Private Sub SetUpTempVars()
    TempVars("Ribbon_btn01") = False
End Sub

now on the open or load event of your form enable this Tempvars

Code:
private sub form_open(cancel as integer)
    TempVars("Ribbon_btn01") = True
    gobjRibbon.Invalidate
end sub

and on the close event of your form:
Code:
private sub form_close()
    TempVars("Ribbon_btn01") = False
    gobjRibbon.Invalidate
end Sub
 
thank you! i will try it.
However may i ask in a different way for a bit different solution.
I make the ribbon via xml with enabled false. Then in the on load event of the form include vba code where this control gets getenabled true. Can it be simplified so? If yes how to refer to the ribbon and its control?
A
 
if you can upload your db without any data just the xml file, or usysribbon, then perhaps i can help you.
 
thanks for the help, however i need to put aside the project for little while. I will get back to you soon. thanks for the help
 

Users who are viewing this thread

Back
Top Bottom