electricpete
Technical User
On tek-tips.com sister site eng-tips.com, someone presented a problem where they end up wanting to use a whole bunch of toggle buttons with a somewhat customized appearance, but they don't want to have to customize the code for each button too mcuh (ideally the same code in each button)
The code that I presented was
The customization that would be required is to change the name of the togglebutton listed after with in each procedure.
It got me to wondering if there is generic way that an event procedure can refer to it's "parent object" (not sure if that's the right term) - in this case the togglebutton. For example, in object modules we can use "me" to refer to the parent object. It doesn't get me to the button in this case because the parent object for this module would be a spreadsheet.
Is there some generic variable or object (similar to "me") that I can substitue into the above code in place of ToggleButton2 ?
The code that I presented was
Code:
Private Sub ToggleButton2_Click()
With ToggleButton2
If .Object.Value Then
.BackColor = &H80000002
Else
.BackColor = &H80000003
End If
End With
End Sub
It got me to wondering if there is generic way that an event procedure can refer to it's "parent object" (not sure if that's the right term) - in this case the togglebutton. For example, in object modules we can use "me" to refer to the parent object. It doesn't get me to the button in this case because the parent object for this module would be a spreadsheet.
Is there some generic variable or object (similar to "me") that I can substitue into the above code in place of ToggleButton2 ?