Dim m
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call CentreCommnetaire Target
End Sub
Private Sub CentreCommnetaire(ByVal Target As Range)
If m <> "" Then Range(m).Comment.Visible = False
If Not Target.Comment Is Nothing Then
Application.ScreenUpdating = False
Target.Comment.Visible = True
Call CentreImage Target.Comment.Shape
m = Target.Address
Application.ScreenUpdating = True
Else
m = ""
End If
End Sub
Sub CentreImage(Im as Shape)
Dim HautImage As Long, GaucheImage As Long
Application.ScreenUpdating = False
With ActiveWindow.ActivePane.VisibleRange
HautImage = .Top + (.Height / 2)
GaucheImage = .Left + (.Width / 2)
End With
With ActiveSheet.Shapes(Im)
.Top = HautImage - (.Height / 2)
.Left = GaucheImage - (.Width / 2)
End With
Application.ScreenUpdating = True
End Sub
Option Explicit
Sub CentreImage()
Dim HautImage As Long, GaucheImage As Long
Dim X As Byte
Application.ScreenUpdating = False
For X = 1 To 30
On Error Resume Next
With ActiveWindow.ActivePane.VisibleRange
HautImage = .Top + (.Height / 2)
GaucheImage = .Left + (.Width / 2)
End With
With ActiveSheet.Shapes("Commentaire " & X)
.Top = HautImage - (.Height / X * 1.75)
.Left = GaucheImage - (.Width / 2)
End With
Next X
Application.ScreenUpdating = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call CentreImage
End Sub
Option Explicit
Dim m As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call CentreCommnetaire1(Target)
End Sub
Private Sub CentreCommnetaire1(ByVal Target As Range)
Dim HautImage As Long, GaucheImage As Long
If m <> "" Then Range(m).Comment.Visible = False
If Not Target.Comment Is Nothing Then
Application.ScreenUpdating = False
Target.Comment.Visible = True
With ActiveWindow.ActivePane.VisibleRange
HautImage = .Top + (.Height / 2)
GaucheImage = .Left + (.Width / 2)
End With
With Target.Comment.Shape
.Top = HautImage - (.Height / 2)
.Left = GaucheImage - (.Width / 2)
End With
m = Target.Address
Application.ScreenUpdating = True
Else
m = ""
End If
End Sub