Change ribbon toggle button state

Rolly_Sefu

Board Regular
Joined
Oct 25, 2013
Messages
149
Hello I have a toggle button added to the ribbon (xml way)

and I have the following code:

Code:
Sub ribbonbutton1(control As IRibbonControl, ByRef cancelDefault)
    If Sheets("Database").Range("I2") = "Yes" Then           'check if master
        If Sheets("Database").Range("I4") <> "Yes" Then    'check if button is pressed
            Sheets("Database").Range("I4") = "Yes"              'declare button is pressed Yes
            Sheets("Board").Visible = True
        Else
            Sheets("Database").Range("I4") = ""                   'reset pressed status to no
            Sheets("Board").Visible = xlVeryHidden
        End If
    Else
        MsgBox "You do not have the permission to make this change !", vbCritical, "STOP"
        State = False  ' => this does not work
    End If
 End Sub

I have created this button to add a functionality for a number of user that access the file.

The user that presses the button does not have the right to change, gets the error message.
But the button remains press. - this is the problem

And I can not figure out how to make the "State = False" work.

Help please.
 
Last edited:

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Here is the xml code if it helps

HTML:
<!--RibbonX Visual Designer 1.94 for Microsoft Excel 16.0. XML Code produced on 2018.04.20-->
<customUI  xmlns="http://schemas.microsoft.com/office/2006/01/customui" >
 <ribbon >
  <tabs >
   <tab 
    id="Tab1"
    insertBeforeMso="TabHome"
    label="CM">
    <group 
     id="Group1"
     label="General">
     <toggleButton 
      id="Togglebutton1"
      imageMso="AutoSum"
      label="Master"
      size="large"
      getPressed="ribbonbutton11"
      onAction="ribbonbutton1"/>
    </group >
   </tab >
  </tabs >
 </ribbon >
</customUI >
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

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