1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Dim maLigne As Shape
'Affecte la variable maLigne à la ligne nommée LaLigne
On Error Resume Next
Set maLigne = ActiveSheet.Shapes("LaLigne")
On Error GoTo 0
'Si LaLigne n'existe pas, on la crée
If maLigne Is Nothing Then
Set maLigne = ActiveSheet.Shapes.AddLine(300, 50, 700, 500)
With maLigne
.Line.ForeColor.RGB = RGB(255, 0, 0)
.Name = "Laligne"
End With
MsgBox "créée"
Else
MsgBox "LaLigne existe déjà"
End If
'on est sûr de l'existence d'une ligne appelée LaLigne
maLigne.Left = 0
MsgBox "LaLigne déplacée"
Set maLigne = Nothing |