Option Explicit
Dim MesBoutons() As New Classe1
Private Sub Workbook_Activate()
Dim OleObj As OLEObject
Dim I As Integer
'For Each OleObj In Me.Sheets(1).OLEObjects
For Each OleObj In ActiveSheet.OLEObjects
If TypeName(OleObj.Object) = "CommandButton" Then
I = I + 1
ReDim Preserve MesBoutons(1 To I)
Set MesBoutons(I).Bouton = OleObj.Object
End If
Next OleObj
End Sub
'code du module de classe
Option Explicit
Public WithEvents Bouton As MSForms.CommandButton
Private Sub Bouton_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With Bouton
If X < 5 Or X > .Width - 5 Or Y < 5 Or Y > .Height - 5 Then .BackColor = &H8000000F Else .BackColor = &HFF&
End With
End Sub