ilk kod form açıldığında olayına eklenecek
Dim ctl As Control
For Each ctl In Me
Debug.Print ctl.Name & " - " & ctl.ControlType 'bu satıra gerek yok hata durumunda hangi kontrolde sorun çıktı onu anlamak için
If ctl.ControlType <> 112 And ctl.ControlType <> 111 Then
ctl.OnClick = "=HandleClick([" & ctl.Name & "])"
Else
ctl.OnEnter = "=HandleClick([" & ctl.Name & "])"
End If
Next ctl
aslında Debug.Print ctl.Name & " - " & ctl.ControlType satırına gerek yok hata durumunda hangi kontrolde sorun çıktı onu anlamak içindiğer kod forma eklenecek birfonksiyon
Public Function HandleClick(ByRef ctl As Control)
Me.BUTONEYLEMI = ctl.Name
End Function