1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
Option Explicit
Private ShCarte As Worksheet
Private Forme As Shape
Private CarteEtudiee As Shape
Sub RepresenterLesPointsSurUneCarte()
Dim AireDesPointsARepresenter As Range
Dim CellulePoint As Range
Dim LigneDeTitre As Long
Dim DerniereLigne As Long
Set ShCarte = Sheets("Feuil1")
With ShCarte
' Suppression des points existants
'---------------------------------
For Each Forme In .Shapes
If Mid(Forme.Name, 1, 5) = "Point" Then Forme.Delete
Next Forme
' Définition de l'aire des points
'--------------------------------
LigneDeTitre = 10
DerniereLigne = .Cells(.Rows.Count, 1).End(xlUp).Row
Set AireDesPointsARepresenter = .Range(.Cells(LigneDeTitre + 1, 1), .Cells(DerniereLigne, 1))
' Définition de la carte
'-----------------------
Set CarteEtudiee = ShCarte.Shapes("Image 1")
' Création des points
'--------------------
For Each CellulePoint In AireDesPointsARepresenter
CreerUneCoordonnee ShCarte, CellulePoint, CellulePoint.Offset(0, 1), CellulePoint.Offset(0, 2), CarteEtudiee
Next CellulePoint
Set CarteEtudiee = Nothing
Set AireDesPointsARepresenter = Nothing
Set ShCarte = Nothing
End With
End Sub
Sub CreerUneCoordonnee(ByVal FeuilleCoordonnee As Worksheet, ByVal Longitude As Double, ByVal Latitude As Double, ByVal NumeroDOrdre As String, ByVal CarteEnCours As Shape)
With FeuilleCoordonnee
Set Forme = .Shapes.AddShape(msoShapeOval, Longitude + CarteEnCours.Left, Latitude + CarteEnCours.Top, 18, 18)
With Forme
.Name = "Point " & NumeroDOrdre
With .Fill
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorBackground1
End With
With .Line
.Visible = msoTrue
.Weight = 1.5
End With
With .TextFrame2
.VerticalAnchor = msoAnchorMiddle
.WordWrap = msoFalse
With .TextRange
.Text = NumeroDOrdre
.ParagraphFormat.Alignment = msoAlignCenter
With .Font
.Size = 8
.Name = "Arial"
.Bold = True
.Fill.ForeColor.ObjectThemeColor = msoThemeColorText1
End With
End With
End With
End With
Set Forme = Nothing
End With
End Sub
Sub SupprimerLesPointsSurUneCarte()
Set ShCarte = Sheets("Feuil1")
With ShCarte
' Suppression des points existants
'---------------------------------
For Each Forme In .Shapes
If Mid(Forme.Name, 1, 5) = "Point" Then Forme.Delete
Next Forme
Set ShCarte = Nothing
End With
End Sub |
Partager