Excel 2007 Ribbon ToggleButton

Boswell

Board Regular
Joined
Jun 18, 2010
Messages
224
I have an excel add-in that has a custom tab on the ribbon, and on this tab is a toggle button. The only action that occurs when the toggle button is pressed is that a cell is set equal to false or true.

Code:
Sub Toggle_is_clicked(control As IRibbonControl, pressed As Boolean)

    Dim ws As Worksheet
    Set ws = ActiveWorkbook.Worksheets(1)
    If pressed = True Then
        ws.Cells(1, 11) = True
    Else
        ws.Cells(1, 11) = False
    End If
  
End Sub

The state of the cell linked to the toggle button affects what procedures occur when a macro is run.

My problem is that certain procedures should not be run while the toggle button is pressed. If the user forgets to unpress the toggle button when performing one of these procedures I would like to automatically unpress the button. It is easy to set the affected cell = false, but I would like the state of the cell and the toggle button to match. Does anyone know how to access and press a toggle button on the excel 2007 ribbon from a macro?

Thank you in advance.
 
It should be:
o n L o a d
and not
O n L o a d
Note that it is case sensitive. (without all the spaces, of course!)
 
Upvote 0
Boswell,
could you post your final code for this toggle button? I'm having, what I assume were similar issues to yours. I have a toggle button that I want to be pressed onOpen if a filter is active or disabled is the list isn't filtered. When the toggle is clicked it will filter or unfilter accordingly. Been messing around for about 2 hours, reading and not having luck. If you could post your xml and VBA that relates to your toggle, it would be very helpful!

Thanks
 
Upvote 0
Sorry, I have no idea what happened to that code. I am pretty sure the way I solved the problem was by adding a routine to the workbook close event that made things so that they would be in sync with the toggle button the next time the workbook was opened. In my case if togglepressed = true then a cell value was set equal to true... so i just made sure to set that value to false on workbook close (because toggle would not be pressed on workbook open).
 
Upvote 0

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