|
Private Sub CommandButton1_Click()
Rem draw the red block
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 0, 0, 400, 300).Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 2
Selection.ShapeRange.Line.ForeColor.SchemeColor = 2
Rem draw the blue block
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 0, 0, 200, 150).Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 4
Selection.ShapeRange.Line.ForeColor.SchemeColor = 4
Rem draw the 12 light
r1 = 400 / 6
r2 = 400 / 12
ww = 400 / 4
hh = 300 / 4
For i = 1 To 12
theta = i * 6.283 / 12
X1 = ww + r2 * Cos(theta + 6.283 / 24)
Y1 = hh + r2 * Sin(theta + 6.283 / 24)
X2 = ww + r1 * Cos(theta + 6.283 / 12)
Y2 = hh + r1 * Sin(theta + 6.283 / 12)
X3 = ww + r2 * Cos(theta + 6.283 / 8)
Y3 = hh + r2 * Sin(theta + 6.283 / 8)
With ActiveSheet.Shapes.BuildFreeform(msoEditingAuto, X1, Y1)
.AddNodes msoSegmentLine, msoEditingAuto, X2, Y2
.AddNodes msoSegmentLine, msoEditingAuto, X3, Y3
.AddNodes msoSegmentLine, msoEditingAuto, X1, Y1
.ConvertToShape.Select
End With
Selection.ShapeRange.Line.ForeColor.SchemeColor = 9
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 9
Next i
Rem draw the circle
ActiveSheet.Shapes.AddShape(msoShapeOval, 66, 42, r1, r1).Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 9
Selection.ShapeRange.Line.Weight = 5
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.ForeColor.SchemeColor = 4
End Sub
本文於 修改第 1 次
|