Sub go(): t = Timer: Set thisworkbook.Cmbrs = Application.CommandBars: End Sub
Sub alt(): Set thiswokbook.Cmbrs = Nothing: TimerOnStop Timer - t: End Sub
'pseudo events on timer
Sub Ontimer(Optional TimeElapsed As Double) 'action pendant le timer
[B1] = Format(Now, "hh:nn:ss")
On Error GoTo fin
[B2] = Format((TimeElapsed) / 86400, "hh:mm:ss ") & "0" & Left(Split(TimeElapsed & "000", ",")(1), 2)
GetCursorPos pos
[B3] = "x=" & pos.X
[B4] = "y=" & pos.Y
Set obj = ActiveWindow.RangeFromPoint(pos.X, pos.Y)
'MsgBox TypeName(obj)
Select Case TypeName(obj)
Case "Range"
[B5] = "Range " & obj.Address: [C5] = ""
Case Else
Select Case True
Case TypeOf obj Is OLEObject
[B5] = "OLEObject"
[C5] = obj.Name
Case ActiveSheet.Shapes(obj.Name).Type = 1 ' si c'est une shape
[B5] = "shape"
[C5] = obj.Name
Case ActiveSheet.Shapes(obj.Name).Type = 8 ' si c'est un control formulaire
[B5] = "control formulaire"
[C5] = obj.Name
Case ActiveSheet.Shapes(obj.Name).Type = 13 ' si c'est une picture
[B5] = "picture"
[C5] = obj.Name
Case ActiveSheet.Shapes(obj.Name).Type = 24 ' si c'est une picture
[B5] = TypeName(obj)
[C5] = obj.Name
Case TypeName(obj) = "ChartObject"
[B5] = TypeName(obj)
[C5] = obj.Name
End Select
End Select
fin:
Err.Clear
End Sub
'pseudo events timer stop
Sub TimerOnStop(Optional TimeElapsed As Double = 0)
[B1:C5].ClearContents
' faire quelque chose ici quand on arrete
End Sub