Option Explicit
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
On Error GoTo Shape_Deleted
Sh.Shapes("InfoBulle").Delete
Shape_Deleted:
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
'source:[-160310-DaCat1997-]
'adaptation Staple, le 21/5/18 pour arthour973
Dim TopIs&, LeftIs&, i%
If Not Intersect(Target, Range("D4:D30")) Is Nothing Then
On Error GoTo Shape_Does_Not_Exist
With Sh.Shapes("InfoBulle")
For i = 1 To Target.Row
TopIs = TopIs + Sh.Cells(i, 1).RowHeight
Next i
.Top = TopIs - 22
For i = 1 To Target.Column
LeftIs = LeftIs + (Sh.Cells(1, i).ColumnWidth * 5.7)
Next i
.Left = LeftIs
.OLEFormat.Object.Text = "Bonjour," & Application.UserName
.Visible = msoTrue
.TextFrame2.VerticalAnchor = 3 ' à commenter si plantage (selon version XL)
.TextFrame2.HorizontalAnchor = 2' à commenter si plantage (selon version XL)
End With
Else
On Error GoTo Shape_Deleted
Sh.Shapes("InfoBulle").Delete
End If
Exit Sub
Shape_Does_Not_Exist:
On Error GoTo 0
Sh.Shapes.AddShape(msoShapeLeftArrow, 0, 0, 115, 30).Name = "InfoBulle"
Resume
Shape_Deleted:
End Sub