Search code examples
excelvbatogglebutton

Using ToggleButton's false .Value to remove the grey color on top when it is clicked


I'm trying to make a ToggleButton look always black but when clicked there's always this grey mask appearing on top (probably for the "clicked" effect) :

Without the grey on topWith the grey on top

I found that with the false .Value of the ToggleButton you can remove it but my problem is now that the userform I'm making appear is appearing again once closed. Is there a way to fix that ? This is my sub for when you click the button :

Private Sub ToggleButton1_Click()

    ToggleButton1.Value = False
    ToggleButton1.Caption = "Afficher l'interface"
    ToggleButton1.ForeColor = RGB(255, 255, 255)
    ToggleButton1.BackColor = RGB(0, 0, 0)
    UF_Interface.Show 'Userform I want to show when you click the button

End Sub

Thanks


Solution

  • With the help of @karma I modified my code this way (since I couldn't change the color of a "normal" Button even though I wanted it's way of working) :

    Private Sub ToggleButton1_Click()
        With ToggleButton1
            If .Value = True Then
                .Caption = "Afficher l'interface"
                .BackColor = vbBlack
                .Value = False
                UF_Interface.Show 'Userform I wanted to show
            End If
        End With
    End Sub