Option Explicit
Private memShp As Shape
Private WithEvents wbk As Workbook
Public Event GetFocus(shp As Shape)
Public Event LostFocus(shp As Shape)
Public Sub ShapeClic(shp As Shape)
FreeShape
Set memShp = shp
RaiseEvent GetFocus(memShp)
End Sub
Private Sub FreeShape()
If Not memShp Is Nothing Then RaiseEvent LostFocus(memShp)
Set memShp = Nothing
End Sub
Private Sub Class_Initialize()
Set wbk = ThisWorkbook
End Sub
Private Sub wbk_BeforeClose(Cancel As Boolean)
FreeShape
End Sub
Private Sub wbk_Deactivate()
FreeShape
End Sub
Private Sub wbk_SheetActivate(ByVal Sh As Object)
FreeShape
End Sub
Private Sub wbk_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
FreeShape
End Sub