Ribbon GetEnabled Callback

nosdude

New Member
Joined
Jun 3, 2010
Messages
7
Hi,

I've been battleing over this for sometime now. I've created a custom ribbon with a range of buttons and dropdown menus. So far I have been able to get code to run when using OnAction commands for buttons, but I am now trying to use Callbacks to change the enabled state of a dropdown or change the item selected in the dropdown - but this whole business of callbacks and how to use them is really confusing me.

For example I am trying to enable a dropdown called Audience when the sheet called Audience is selected.

This is my code for the Callback

Code:
Public Sub AudienceGetEnabled(control As IRibbonControl, ByRef returnedVal)
'
' Code for getEnabled callback. Ribbon control dropDown
'

If ActiveSheet.Name = "Audience" Then
    returnedVal = Enabled
End If
    

End Sub

And this is the code I have when the sheet Audience is selected.

Code:
Private Sub Worksheet_Activate()
AudienceGetEnabled
End Sub

I get an 'Argument not Optional' error when trying to run this Worksheet_Activate code, which from what I've been able to find out online has something to do with the ByRef argument given in the AudienceGetEnabled sub.

I also thought this might work on the Worksheet_Activate code but I get an Object required error

Code:
Private Sub Worksheet_Activate()

control.AudienceGetEnabled.returnVal = Enabled

End Sub


Any help would be greatly appreciated.

Thanks
 
I think I should just add to this for anyone else that may encounter this in the future.
There's a little bug that I have noticed. Every time I edit something in visual basics editor the Rib.Invalidate stops working (i.e. I get an error when it runs). But if you save, close the file and then reopen it the Rib.Invalidate command works again and the new code you entered also works.
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top