Reset Togglebutton status

Hi rorya (probably :) )

In my ADDIN, I have a Togglebutton that enables functions relating to Autofilter in a worksheet.

When the Togglebutton is clicjed, the callback checks tosee if filtering is present in the sheet.  If no filtering is present, nothing is done.

However the Togglebutton remains selected.  I have tried setting GetPressed to false and invalidating the control andeven the ribbon but it remains set.  I have attached the callback and getlabel below.

Many thanks!

Robert
' Callback for FilterHighlight Togglebutton
Sub RibbonAction_Filter_FuncAddin(control As IRibbonControl, pressed As Boolean)
If ActiveSheet.FilterMode Or ActiveSheet.AutoFilterMode Then
gbFilterHighlightPressed = pressed
oRibbon.InvalidateControl control.ID        '   Executes the Getlabel function
gsRunFunc = "'" & ThisWorkbook.Name & "'!" & "M_Perform_Function"
s_Doit = Application.Run(gsRunFunc, control.ID)
Else
' Deactivate the togglebuttonstatus

End If
End Sub
Sub FilterHighlight_GetLabel(control As IRibbonControl, ByRef returnedVal)
If gbFilterHighlightPressed Then
returnedVal = "Active Filters Highlighted"
Else
returnedVal = "Apply Filter Highlights"
End If
End Sub

Open in new window

RODELSAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rory ArchibaldCommented:
Where is your GetPressed callback (or whatever you have called it)? It needs to be a function that returns either True or False.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RODELSAuthor Commented:
Oops:

Sub FilterHighlight_GetPressed(control As IRibbonControl, ByRef returnedVal)
If gbFilterHighlightPressed Then
returnedVal = True
Else
returnedVal = False
End If
End Sub

Open in new window

0
Rory ArchibaldCommented:
Where do you set it to false?
Might be easier if you can post the add-in so I can check the CustomUI too.
0
RODELSAuthor Commented:
Hi rory,
Actually your question about the getPressed callback made me realise what the problem was.  It is now working fine as listed.

Long may you rule at the top of the leaderboard!  Thanks you so much for your help the last couple of days.

Robert
' Callback for FilterHighlight Togglebutton
Sub RibbonAction_Filter_FuncAddin(control As IRibbonControl, pressed As Boolean)
If ActiveSheet.FilterMode Or ActiveSheet.AutoFilterMode Then
gbFilterHighlightPressed = pressed
oRibbon.InvalidateControl control.ID
gsRunFunc = "'" & ThisWorkbook.Name & "'!" & "M_Perform_Function"
s_Doit = Application.Run(gsRunFunc, control.ID)
Else
' Deactivate the togglebuttonstatus
gbFilterHighlightPressed = False
oRibbon.InvalidateControl control.ID
End If
End Sub
Sub FilterHighlight_GetLabel(control As IRibbonControl, ByRef returnedVal)
If gbFilterHighlightPressed Then
returnedVal = "Active Filters Highlighted"
Else
returnedVal = "Apply Filter Highlights"
End If
End Sub
Sub FilterHighlight_GetPressed(control As IRibbonControl, ByRef returnedVal)
If gbFilterHighlightPressed Then
returnedVal = True
Else
returnedVal = False
End If
End Sub

Open in new window

0
Rory ArchibaldCommented:
Glad to help. :)

Merry Christmas (if we don't speak again beforehand...)!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.