'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) :
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 1:[1]
If I may suggest, if you want to use the ToggleButton,
maybe it's better making a two condition (if true then what, if false then what),
such as the image below :
So in the image above, if true then open the other UF - if false then close that UF.
Below is the code in the UF where the ToggleButton reside :
Private Sub UserForm_Initialize()
With ToggleButton1
.Caption = "OPEN UF_Interface"
.BackColor = vbYellow
End With
End Sub
Private Sub ToggleButton1_Click()
With ToggleButton1
If .Value = True Then
.Caption = "CLOSE UF_Interface"
.BackColor = vbGreen
UF_Interface.Show vbModeless
Else
.Caption = "OPEN UF_Interface"
.BackColor = vbYellow
Unload UF_Interface
End If
End With
End Sub
Both userforms (UF_Interface and the one with the toggle button) must be shown in vbModeless state. So you need to make another sub in regular module, something like below :
Sub OpenFormWithToggleButton()
FormWithToggleButton.Show vbModeless
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |



