Get state of toggleButton in custom Excel Ribbon?

JanKb

New Member
Joined
Feb 4, 2021
Messages
1
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hey everyone,

I've been trying to solve the problem for a while now, but I cannot find a suitable solution online.

I have created a custom Ribbon which is loaded as an Add-In into my Workbooks. In this Ribbon I have a Toggle Button A and some other button, let's call it Button B. What I need is the follwing:

When pressing Button B, a specified procedure is taking place. During this procedure I need to know whether the Toggle Button A is pressed or not. Is there any way / function to easily read the stat of the button? I already tried to declare a boolean to store the value each time the toggle button is pressed (onAction), but unfortunately the variable is not stored in each Workbook seperately. So if I have two Workbooks open, it might happen that the toggle button is pressed, but the variable is false as this is the state in another Workbook.

Maybe anyone has a clever solution for this. It seems like a basic problem to me, to read the state of a button, but I still can't find a solution.

Many thanks and best regards,
Jan
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,364
Depending on the conditions you use to determine the Pressed state of the button you can use the Activeworkbook object in your callback.
Another way is to use a 2D array type variable and to store the workbook name along with the button pressed state.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,368
Messages
5,624,286
Members
416,018
Latest member
mirceaon

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
Top