Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim triArray(1 To 4, 1 To 2) As Single
triArray(1, 1) = 25 'Assign values in code, Or
triArray(1, 2) = 100 'Read a table of values in the sheet
triArray(2, 1) = 100
triArray(2, 2) = 150
triArray(3, 1) = 150
triArray(3, 2) = 50
triArray(4, 1) = 25 ' Last point has same coordinates as first
triArray(4, 2) = 90 ' else not filled as a solid
Set myDocument = Worksheets(1)
myDocument.Shapes.AddPolyline triArray
Set myDocument = Worksheets(1)
With myDocument.Shapes.AddLine(10, 10, 250, 250).Line
.DashStyle = msoLineDashDotDot
.ForeColor.RGB = RGB(50, 0, 128)
End With
With myDocument.Shapes.AddShape(msoShapeRectangle, 144, 144, 72, 72)
.Name = "Red Square"
.Fill.ForeColor.RGB = RGB(255, 0, 0)
.Line.DashStyle = msoLineDashDot
End With
End Sub